Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4j initialization issue

Tags:

java

jboss

log4j

First of all I need to say that I'm newbie in Java and Java-related technologies.
Recently I got a big project in Java. It has client and server sides. When I'm trying to call client-side application, it gives me following warning:

`log4j:WARN No appenders could be found for logger (org.jboss.security.SecurityAssociation).  
log4j:WARN Please initialize the log4j system properly.`  

Ok, it seems like log4j can't find its properties file. I didn't find any, so I wrote a new one:

log4j.rootLogger=info, stdout, file

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.file=server.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n`

And now I have no idea where I have to put it. Documentation says, that it has to be in classpath - so I tried to put it into /src/ subdirectory of client, web and webinfo folders. I also tried the root folder of project - but it keeps giving me warnings.
Does anybody know good manual on "How to find a place to put log4j.properties file" topic? Or maybe I have to write somewhere in jboss configuration files that I'm using the following log4j.properties file?

like image 209
aga Avatar asked Jul 14 '26 18:07

aga


1 Answers

You can configure log4j properties in different ways,

  • As you said, it has to be in classpath, For any web application default classpath would be WEB-INF/classes, You can place log4j.properties file there. If it is not web application, try to find where all your classes resides, usually inside bin folder.
  • Other way is you can configure it via VM args

-Dlog4j.configuration=file:/C:/testing/mylog4j.properties

like image 181
RP- Avatar answered Jul 18 '26 11:07

RP-