Log4j: WARN No log applications found (running jar file, not web application)

First of all, yes, I read several questions and answers on this topic, and I can not find any of the solutions that would help me. I do not use Tomcat or JBoss, and I do not have the web.xml to modify. I am using Java 6.0 and log4j-1.2.8.jar .

I am creating a JAR executable with IntelliJ IDEA with JAR libraries packaged separately and linked through a manifest. I run my code on a Linux server this way:

 me@server:/mydir> java -jar code/myjar.jar log4j:WARN No appenders could be found for logger (FactoredEventsForTrna). log4j:WARN Please initialize the log4j system properly. 

My mydir configuration file (which I put in mydir and mydir/code , just in case):

 ## Logger configure file for myproject log.dir=log/ datestamp=yyyy-MM-dd/HH:mm:ss.SSS log4j.rootLogger=TRACE, file, proappender, console log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.maxFileSize=1GB log4j.appender.file.maxBackupIndex=5 log4j.appender.file.File=log/mydebug.log log4j.appender.file.threshold=TRACE log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{${datestamp}} %5p: %c{2} - %m%n log4j.appender.proappender=org.apache.log4j.RollingFileAppender log4j.appender.proappender.maxFileSize=5GB log4j.appender.proappender.Threshold=INFO log4j.appender.proappender.File=log/myinfo.log log4j.appender.proappender.layout=org.apache.log4j.PatternLayout log4j.appender.proappender.layout.ConversionPattern=%d{${datestamp}} %5p: %c{2} - %m%n log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Threshold=DEBUG log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{${datestamp}} %5p: %c{2} - %m%n 

And I created the log/ directory in mydir and mydir/code , again, just in case.

Any ideas?

+52
java log4j
Jul 03 2018-12-12T00:
source share
7 answers

There are many possible options for configuring log4j. One of them is that the file will be called exactly "log4j.properties" and be in your class path. Another is to name it as you want and add the System property to the command line when starting Java, for example:

 -Dlog4j.configuration=file:///path/to/your/log4j.properties 

They are all described here http://logging.apache.org/log4j/1.2/manual.html#defaultInit

+57
Jul 03 2018-12-12T00:
source share

Decision

  1. Download log4j.jar file
  2. Add the log4j.jar file to build the path
  3. Call Recorder by:

     private static org.apache.log4j.Logger log = Logger.getLogger(<class-where-this-is-used>.class); 
  4. if the log4j properties do not exist, create a new log4j.properties file file a new file in the bin directory:

     /workspace/projectdirectory/bin/ 

Sample log4j.properties file

 log4j.rootLogger=debug, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%t %-5p %c{2} - %m%n 
+43
Feb 13 '13 at 4:19
source share

I moved my log4j.properties file to the resources folder and it worked fine for me!

+9
Sep 10 '14 at 8:33
source share

Man, I had a problem in one of my eclipse projects, surprisingly the problem was that there were bans in my .project file. believe it or not!

+3
Feb 11 '14 at 23:05
source share

You will find log4j.properties in solr / examples / resources .

If you do not find the file, I will put it here:

 # Logging level solr.log=logs/ log4j.rootLogger=INFO, file, CONSOLE log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x \u2013 %m%n #- size rotation with log cleanup. log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.MaxFileSize=4MB log4j.appender.file.MaxBackupIndex=9 #- File to log to and log format log4j.appender.file.File=${solr.log}/solr.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m\n log4j.logger.org.apache.zookeeper=WARN log4j.logger.org.apache.hadoop=WARN # set to INFO to enable infostream log messages log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF 

Hello

+2
Feb 17 '14 at 18:47
source share

Move the log4j.properties file to the src folder. Open Windows Explorer, go to the directory where your project is located. Go to the bin directory and delete all the folders with it.

Now in the eclipse project, click the project ----> clean ----> OK

This would force him to create the project again, all the contents deleted from the bin directory would be recreated.

I took to figure it out. From time to time, a direct press on the clear button does not work

+1
Aug 6 '14 at 4:08
source share

put the folder in which there is a properties file to enter the source of the java build path. You can add it by right-clicking the project ----> build path -----> configure the build path ------> add t

0
Mar 20 '14 at 2:05
source share



All Articles