Embed Apache ZooKeeper in Jetty generates Debug log message - log4j

I am using Jetty 8 and ZooKeeper 3.4.5. When I connect to ZooKeeper, jetty keep generating DEBUG level message. How to suppress it?
16:54:56.757 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:56.758 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:56.758 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:56.759 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:56.760 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:56.760 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x13ddc6e9a2b000c after 3ms
16:54:56.760 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:58.424 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:58.425 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:58.425 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:58.426 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:58.427 [main-SendThread(127.0.0.1:2181)] DEBUG o.a.z.client.ZooKeeperSaslClient - Could not retrieve login configuration: java.lang.SecurityException: Unable to locate a login configuration
16:54:58.427 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x13ddc6e9a2b000c after 2ms
I added log4j.properties under src folder:
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r - [%t] %-5p %c %x - %m%n
log4j.logger.org.apache.zookeeper.ZooKeeper=INFO
Still no luck.

I have checked again my included library, and I found out that LogBack was included. I think JVM load logback instead of log4j. Once I supply logback.xml, the problem is solved.

Something like this in config should help:
<logger name="com.apache.zookeeper" level="info">
<!-- appenders -->
</logger>

Related

Apache Pulsar Zookeeper: Unable to access datadir, exiting abnormally

I am using these steps to use apache pulsar on docker: https://github.com/streamnative/tgip/blob/master/episodes/001/demo.md
I was able to use these steps before to install and use pulsar but for some reason now when am creating a directory, it is going to write protected and pulsar zookeeper container is exiting with following logs as soon as it is created:
ERROR org.apache.zookeeper.server.ZooKeeperServerMain - Unable to access datadir, exiting abnormally
org.apache.zookeeper.server.persistence.FileTxnSnapLog$DatadirException: Unable to create data directory data/zookeeper/version-2
at org.apache.zookeeper.server.persistence.FileTxnSnapLog.<init>(FileTxnSnapLog.java:136) ~[org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:137) ~[org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:112) ~[org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:67) [org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:140) [org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:90) [org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
Unable to access datadir, exiting abnormally
23:36:15.223 [main] INFO org.apache.zookeeper.audit.ZKAuditProvider - ZooKeeper audit is disabled.
23:36:15.226 [main] ERROR org.apache.zookeeper.util.ServiceUtils - Exiting JVM with code 3
23:36:15.196 [PurgeTask] ERROR org.apache.zookeeper.server.DatadirCleanupManager - Error occurred while purging.
org.apache.zookeeper.server.persistence.FileTxnSnapLog$DatadirException: Unable to create data directory data/zookeeper/version-2
at org.apache.zookeeper.server.persistence.FileTxnSnapLog.<init>(FileTxnSnapLog.java:136) ~[org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at org.apache.zookeeper.server.PurgeTxnLog.purge(PurgeTxnLog.java:80) ~[org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at org.apache.zookeeper.server.DatadirCleanupManager$PurgeTask.run(DatadirCleanupManager.java:141) [org.apache.zookeeper-zookeeper-3.6.3.jar:3.6.3]
at java.util.TimerThread.mainLoop(Timer.java:556) [?:?]
at java.util.TimerThread.run(Timer.java:506) [?:?]
23:36:15.229 [PurgeTask] INFO org.apache.zookeeper.server.DatadirCleanupManager - Purge task completed
I have made sure that SELinux is disabled and tried changing permission using chmod 777 data/ and every other step available to resolve this but still unable to find any. Please help me with the possible resolution.

log4j-1.2-api bridge ClassNotFoundException:org.apache.log4j.RollingFileAppender

I try to migrate my application from log4j to log4j2. According to official manual I have org.apache.logging.log4j:log4j-1.2-api:2.17.1, org.apache.logging.log4j:log4j-api:2.17.1 and org.apache.logging.log4j:log4j-core:2.17.1 in my maven dependencies. I use log4j.properties file so I enabled compatibility mode (-Dlog4j1.compatibility=true). RollingFileAppender is configured in my log4j.properties file:
log4j.appender.A2=org.apache.log4j.RollingFileAppender
I get following error:
2022-02-16 21:04:20,396 main ERROR Unable to create Appender org.apache.log4j.RollingFileAppender due to ClassNotFoundException:org.apache.log4j.RollingFileAppender
According to official manual, RollingFileAppender is a supported component. I had log4j:log4j:1.2.17 dependency before migration to log4j2 and it contains org.apache.log4j.RollingFileAppender class. Unfortunately none of the log4j-1.2-api,log4j-api and log4j-core libraries contain this class. I do not understand why RollingFileAppender is not present in log4j bridge if manual says that RollingFileAppender is supported component. I have found similar question but without a satisfactory answer. How to migrate RollingFileAppender?
UPDATE
Here is my log4j.properties file:
log4j.rootCategory=INFO, A1, A2
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d%m%M %n
log4j.appender.A2.file=C:/projects/test/Log.log
#log4j.appender.A2.layout=org.apache.log4j.PatternLayout
#log4j.appender.A2.layout.ConversionPattern=[%d{dd.MM HH.mm.ss.SSS} %-5p %-20c{1}] : %m%n
#log4j.appender.A2.MaxFileSize=10000KB
#log4j.appender.A2.MaxBackupIndex=3
I added -Dlog4j2.debug=true. There are tons of logs. I chose interesting logs:
TRACE StatusLogger Trying to find [log4j.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader#2437c6dc.
DEBUG StatusLogger Not in a ServletContext environment, thus not loading WebLookup plugin.
DEBUG StatusLogger PluginManager 'Log4j Builder' found 18 plugins
DEBUG StatusLogger Parsing for [root] with value=[INFO, A1, A2].
DEBUG StatusLogger Level token is [INFO].
DEBUG StatusLogger Logger root level set to INFO
DEBUG StatusLogger Parsing appender named "A1".
DEBUG StatusLogger PluginManager 'Converter' found 47 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false
DEBUG StatusLogger Adding appender named [A1] to loggerConfig [].
DEBUG StatusLogger Parsing appender named "A2".
WARN StatusLogger Unable to create File Appender, no file name provided
ERROR StatusLogger Unable to create Appender org.apache.log4j.RollingFileAppender due to ClassNotFoundException:org.apache.log4j.RollingFileAppender
DEBUG StatusLogger Appender named [A2] not found.
DEBUG StatusLogger Finished configuring.
The reason configuration fails is explained by the following message:
WARN StatusLogger Unable to create File Appender, no file name provided
This is caused by a compatibility problem between the Log4j 1.x bridge and the original Log4j 1.x: property names must start with a capital letter (cf. LOG4J2-3316). This will be solved in the next release.
Until then, you can use:
log4j.appender.A2.File=C:/projects/test/Log.log
(with a capital F).

Configure Security Manager on Tomcat7

Trying to configure Security Manager for Tomcat 7. We are running Java 1.8.0_51 on a 64 bit Windows 2008 server and run Tomcat as a service. I've added the following lines as Java Options:
-Djava.security.manager
-Djava.security.policy=D:\Program Files\Apache Software Foundation\Tomcat7.0\conf\catalina.policy
The security policy file is the default file and has not been modified. After adding the lines I can no longer start Tomcat. I get the following error messages:
2015-10-07 08:58:31 Commons Daemon procrun stderr initialized properties: reading security properties file: C:\Program Files\Java\jre1.8.0_51\lib\security\java.security jar: beginEntry META-INF/MANIFEST.MF jar: done with meta! jar: nothing to verify! scl: getPermissions ProtectionDomain (file:/D:/Program%20Files/Apache%20Software%20Foundation/Tomcat7.0/bin/tomcat-juli.jar <no signer certificates>) sun.misc.Launcher$AppClassLoader#c387f44 <no principals> java.security.Permissions#28d93b30 ( ("java.lang.RuntimePermission" "exitVM") ("java.io.FilePermission" "\D:\Program Files\Apache Software Foundation\Tomcat7.0\bin\tomcat-juli.jar" "read") ) scl: policy: reading file:/D:/Program%20Files/Apache%20Software%20Foundation/Tomcat7.0/conf/catalina.policy [Policy Parser]: sun.security.util.PropertyExpander$ExpandException: unable to expand property catalina.home [Policy Parser]: sun.security.util.PropertyExpander$ExpandException: unable to expand property catalina.base
I also see errors like the following:
java.lang.IllegalArgumentException: null KeyStore name
If I remove the new config lines all is well.
Any ideas?

Silence Debug Logging in HTTPComponents

How do I silence the debug logging in http componenets?
09:23:22.145 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
09:23:22.145 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
09:23:22.145 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://example.org:80][total kept alive: 1; route allocated: 1 of 100; total allocated: 1 of 200]
09:23:22.145 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://diagnostics-uat.corp.apple.com:80][total kept alive: 0; route allocated: 1 of 100; total allocated: 1 of 200]
09:23:22.145 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request POST /evt/detect HTTP/1.1
09:23:22.145 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
09:23:22.145 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
09:23:22.145 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /evt/detect HTTP/1.1
09:23:22.145 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 92
I have tried a code based solution:
static {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "warn");
}
public static void main(String[] args) throws Exception {
And this log4j.properties
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n
log4j.logger.org.apache.http=WARN
log4j.logger.org.apache.http.wire=WARN
But neither have worked. Help is appreciated, thanks!
You settings are correct possible causes may be another log4j config file is in the classpath and overriding your config. So I will recommended this.
- Ensure you log4j.properties file is in classpath . Use below command to see open files by a process (assuming unix)
lsof -p java-process-pid | grep log4j
Search for log4j.properties in your runtime folders and get rid of all duplicate files (if possible) - otherwise change them all.
Search for log4j.xml and do the same.
Sometimes I have seen third party jars that ship with a log4j.xml or log4j.properties so in worst case check for all jars using below command
jar -tvf a.jar | grep log4j
Programmatically, it can be set silent with:
(Apache HttpComponents 4.3.5)
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
...
Logger.getLogger("org.apache.http") .setLevel(Level.WARN);
Logger.getLogger("org.apache.http.wire") .setLevel(Level.WARN);
Logger.getLogger("org.apache.http.headers").setLevel(Level.WARN);

Rexster refuses to start with extension but does not display errors

I have a small Rexster/Titan cluster using Cassandra. A Rexster extension is used to query the graph. I did some benchmarking and did start and stop Rexster/Titan many times. But now I run into a strange issue: Rexster refuses to start but does not display any error message.
I tried to figure out what is causing this and reduced the cluster to a single node 192.168.0.4.
If I remove my extension Rexster manages to start up.
# console output
Forking Cassandra...
Running `nodetool statusthrift`..... OK
(returned exit status 0 and printed string "running").
Forking Titan + Rexster...
Connecting to Titan + Rexster (127.0.0.1:8184)...... OK
(connected to 127.0.0.1:8184).
Run rexster-console.sh to connect.
but when I place my extension uber JAR in the ext folder Rexster refuses to start.
# console output
Forking Cassandra...
Running `nodetool statusthrift`..... OK
(returned exit status 0 and printed string "running").
Forking Titan + Rexster...
Connecting to Titan + Rexster (127.0.0.1:8184)............................
timeout exceeded (60 seconds): could not connect to 127.0.0.1:8184
See /var/lib/titan/bin/../log/rexstitan.log for Rexster log output.
If I now check rexstitan.log, as suggested by the console output, I can not find any error message.
# rexstitan.log
0 [main] INFO com.tinkerpop.rexster.Application - .:Welcome to Rexster:.
73 [main] INFO com.tinkerpop.rexster.server.RexsterProperties -
Using [/var/lib/titan/rexhome/../conf/rexster-cassandra-cluster.xml]
as configuration source.
78 [main] INFO com.tinkerpop.rexster.Application - Rexster is watching
[/var/lib/titan/rexhome/../conf/rexster-cassandra-cluster.xml] for change.
244 [main] INFO com.netflix.astyanax.connectionpool.impl.ConnectionPoolMBeanManager -
Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,
name=ClusterTitanConnectionPool,ServiceType=connectionpool
252 [main] INFO com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor -
AddHost: 192.168.0.4
537 [main] INFO com.netflix.astyanax.connectionpool.impl.ConnectionPoolMBeanManager -
Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,
name=KeyspaceTitanConnectionPool,ServiceType=connectionpool
538 [main] INFO com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor -
AddHost: 192.168.0.4
1951 [main] INFO com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration -
Set cluster.partition=false from store features
1971 [main] INFO com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration -
Set default timestamp provider MICRO
2019 [main] INFO com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration -
Generated unique-instance-id=7f0000012902-node1
2045 [main] INFO com.netflix.astyanax.connectionpool.impl.ConnectionPoolMBeanManager -
Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,
name=ClusterTitanConnectionPool,ServiceType=connectionpool
2046 [main] INFO com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor -
AddHost: 192.168.0.4
2053 [main] INFO com.netflix.astyanax.connectionpool.impl.ConnectionPoolMBeanManager -
Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,
name=KeyspaceTitanConnectionPool,ServiceType=connectionpool
2054 [main] INFO com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor -
AddHost: 192.168.0.4
2228 [main] INFO com.thinkaurelius.titan.diskstorage.Backend -
Initiated backend operations thread pool of size 4
6619 [main] INFO com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog -
Loaded unidentified ReadMarker start time Timepoint[1423479705116000 μs]
into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller#212f3ff1
6625 [main] INFO com.tinkerpop.rexster.RexsterApplicationGraph -
Graph [graph] - configured with allowable namespace [*:*]
The only entry that looks strange to me is the one concerning the log:
6619 [main] INFO com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog -
Loaded unidentified ReadMarker start time Timepoint[1423479705116000 μs]
into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller#212f3ff1
My exception uses the logger for debugging. You can see the instantiation an usage on github: https://github.com/sebschlicht/titan-graphity-kribble/blob/master/src/main/java/de/uniko/sebschlicht/titan/extensions/GraphityExtension.java#L22
Though Rexster failed to start there is a process with the PID displayed in the console but curl fails to connect to Rexster:
$ curl 192.168.0.4:8182
curl: (7) Failed to connect to 192.168.0.4 port 8182: Connection refused
Why doesn't Rexster throw an exception? How can I debug this situation?
edit:
I removed any log messages in my code. I removed all exceptions that may be thrown during startup. Still Rexster refuses to start with my extension and the only hint in the log files is the unidentified read marker. I have to clue what prevents Rexster from starting.
The log message is nothing to worry about.
After rebuilding the application in another project step-by-step Rexster is now able to start with the extension. During this rebuild I noticed two situations, that can cause the behaviour described:
Missing dependency
If your project depends on a second project you might use Maven to inject it as a dependency. However, if you use
mvn clean package
to build the extension's JAR file it does not contain this dependency by default. You need to use a Maven plugin (e.g. maven-shade-plugin) to create a shaded JAR that contains all the dependencies your extension needs. Set the dependency scope to provided for all Titan/Rexster/Blueprints related dependencies. Use the shaded uber-JAR to deploy the extension to Rexster.
However, this was not new to me and should not have caused the problem in my case. There might be more situations that cause this problem or maybe there was a problem with Maven that messed up the shaded JAR. Feel free to browse the commit on github to catch this voodoo.
Missing extension
Another cause of this behaviour is a missing extension.
If you specify an extension in the com.tinkerpop.rexster.extension.RexsterExtension resource file, that is not present on startup, Rexster does neither log nor throw an exception, but refuses to start.

Resources