It shows error when i trying to run the project using socket appender.But it is working fine when i am printing logs on a file.
INFO: Initializing Spring root WebApplicationContext
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Related
I am running multinode Hadoop(3.2.1) in my virtual machine. I have one masternode machine and one slavenode machine.
I am having an error on my datanode logs/userlogs
log4j:WARN No appenders could be found for logger (org.apache.hadoop.mapred.YarnChild).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I spent way too much time on this, I am trying to use log4j instead of spring boot logging, Unfortuantley every time i start my sprint boot app i use to get slf4j binding error as below .
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/doddmani/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.1.11/ccedfbacef4a6515d2983e3f89ed753d5d4fb665/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/doddmani/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.8.2/36bc2a99b86be26ccdc51fe288458dc712d280c1/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
2017-11-21 15:29:51.004 INFO 9692 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-11-21 15:29:51.012 INFO 9692 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.4
2017-11-21 15:29:51.319 INFO 9692 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/faps] : Initializing Spring embedded WebApplicationContext
And I did see there was a dependency in logback.jar when i executed gradle dependency command. I fixed it by adding exclusions in my gradle file as below.
configurations {
all*.exclude module : 'logback-classic'
}
With this fix, i see no more refenrence to logback jars in dependency list, But everytime i run my app again , Its still fetching reference from gradle cache and continues to say SLF4J Binding exceptions. Can any one pls help me getting this issue sorted out.
I've had similar problem. I was trying add log4j2 to my spring boot app, this config fix it to me
configurations.all {
all*.exclude module: 'slf4j-log4j12'
all*.exclude module : 'logback-classic'
}
I have the shutdownhook error in my Spring boot application in which i use log4j2.
I saw that it was a bug in log4j2 and shutdownHook="disable" was suppossed to resolve it. But inspite of using the same i still get the same error.
I am using spring boot version 1.3.7.RELEASE and the dependecy for log4j2 is
spring-boot-starter-log4j2 .
Error which i get whetry to close the session using Ctrl-C
2016-08-23 13:38:56,098 Thread-7 ERROR No log4j2 configuration file found. Using
default configuration: logging only errors to the console.
2016-08-23 13:38:56,105 Thread-7 FATAL Unable to register shutdown hook because
JVM is shutting down. java.lang.IllegalStateException: Cannot add new shutdown h
ook as this is not started. Current state: STOPPED
at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.ad
dShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdownCal
lback(Log4jContextFactory.java:271)
at org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook(LoggerC
ontext.java:256)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:
216)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log
4jContextFactory.java:146)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log
4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:185)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(Abstrac
tLoggerAdapter.java:103)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFac
tory.java:43)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(Abstract
LoggerAdapter.java:42)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFact
ory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at com.worldline.frm.dataloader.policy.CustomQueueRoutePolicy.onStop(Cus
tomQueueRoutePolicy.java:90)
at org.apache.camel.impl.RouteService.doStop(RouteService.java:249)
I am facing one strange problem , I am working on one batch application using below tech STACK
Spring (IOC container) , spring batch , Hibernate , camel and Log4J for logging
I have configured log4J for file appender only and my all application logs goes to my log file , but strange thing is that all Camel logs goes to console appender (I have no console apender configured on my log4J properties file)
Spring – Camel Integration is XMl element :
<camelContext xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="smtBatchRouter" />
</camelContext>
My Log4J configuration:
log4j.rootLogger=TRACE, file
log4j.logger.org.apache=TRACE
log4j.logger.org.directwebremoting=OFF
log4j.logger.org.hibernate=OFF
log4j.logger.org.springframework=WARN
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.file=myapp.log
log4j.appender.file.ImmediateFlush=true
log4j.appender.file.bufferedIO=false
log4j.appender.file.DatePattern='.' dd-MM-yyyy
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
log4j.appender.file.threshold=TRACE
Sample Camel Log that I am getting in console :
[main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel 2.11.0 (CamelContext: camel-1) started in 4.009 seconds
[Camel (camel-1) thread #0 - sftp://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH -> Connecting to localhost port 22
[Camel (camel-1) thread #0 - sftp://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH -> Connection established
[Camel (camel-1) thread #0 - sftp://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH -> Remote version string: SSH-1.99-OpenSSH_4.6
I had the same issue and solved it.
Run your application with the flag:
-Dlog4j.debug
It will add diagnostic information to your console. In my case it was
SLF4J: Class path contains multiple SLF4J bindings.
So I just deleted redundant slf4j-jdk14-1.7.9.jar and left only slf4j-log4j12-1.7.19.jar.
I'm using Jenkins, and I have a Windows machine set up as a slave worker. I have a Maven-based project that runs on the slave. The build works correctly, but I get a warning from log4j about it not being initialized. I'd like to scratch that itch and remove the warning, but I don't know how.
I'm not very familiar with log4j. I do understand I could set a system property to tell it where to find a config file, but I don't know where in the Jenkins pipeline that property should be set or how. It looks like the warning comes before Maven starts but after the slave begins the job.
Here's the snippit of console output:
Parsing POMs
[MyTest] $ java -cp C:\jenkins\maven3-agent.jar;C:\jenkins\tools\Maven\Maven\boot\plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main C:\jenkins\tools\Maven\Maven C:\Users\waisbrot\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\28\5c50da9c-2d1a9aef C:\jenkins\maven3-interceptor.jar 49210
<===[JENKINS REMOTING CAPACITY]===>channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f C:\jenkins\workspace\MyTest\pom.xml test
[INFO] Scanning for projects...
I'm not particularly proud of this, but I wasn't interested in any of that idle chatter, so I suppressed it by doing
jar uf <path to maven3-agent-1.2.jar>/maven3-agent-1.2.jar log4j.xml
where log4j.xml contains
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<root>
<level value="off"/>
</root>
</log4j:configuration>
NB: the jar command must be executed as shown, with log4j.xml in the current directory.
Just provide a log4j.properties or a log4j.xml with valid contents in the classpath. See the log4j documentation for details