aspose file tools*
The moose likes JBoss/WildFly and the fly likes Log4j - log4j.properties configuration for separate logs and not on root logs. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Log4j - log4j.properties configuration for separate logs and not on root logs." Watch "Log4j - log4j.properties configuration for separate logs and not on root logs." New topic
Author

Log4j - log4j.properties configuration for separate logs and not on root logs.

Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 56
Hi,

I do have a problem. We do have 3 application deployed on a JBoss server. All the logs are going to server.log.

Now, I would like to configure application specific logs for each application.

Example:

Application1 - Application1.log
Application2 - Application2.log
Application3 - Application3A.log (only for the packages com.myexample.action)
Application3 - Application3C.log (only for the packages com.myexample.common)

Please help me to setup the Log4j.properties.



Also, All the logs coming on Root log file also. I would like to avoid that too. Application logs should come only on application*.log. How to control it?

Apart from this 1 question:
If the log4j has been confired on log4j.properties (Inside war) and log4j.xml (JBoss one), then which configuration would be taken by log4j?
Ragavendran Baskaran
Greenhorn

Joined: Dec 12, 2011
Posts: 15
I have recently came across the similar problems what you mentioned and I hope this should help.

As per your log4j properties file, you have added your application specific appenders to root logger, Remove your application specific appenders entry against the root logger and give a try.
There is one more property on log4j category named "additivity" which will help you in controlling whether to log an event in to specified appender only or with all appenders in the higher in the hierarchy. you can refer to log4j manual for more information.

Also for your other question on precedence for your log4j property file against jboss-log4j.xml(location - *.war/WEB-INF), It is decided whether you have added this entry in your jboss-web.xml or not.

If this is added, then Jboss will use the log4j property packaged along with the application.
Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 56
Thanks Ragav.

I tried "additivity" flag. It didn't work for me. Also, I have tried to remove log4j.properties and configure log4j.xml (on JBoss config). But, still no luck.

I have tried many combinations of the below code snippet.



In above code snippet, I tried with following combinations:
1. Just Category alone, Just Logger alone, both Category & Logger.
2. In ROOT, with/without BFS.

But, Still I do see the logs go to server.log files, but not BFS.log.

Could you please help me? All I want is, the application logs to go to BFS.log (only BFS.log) and all other JBoss logs to server.log (Except application logs) file.
Ragavendran Baskaran
Greenhorn

Joined: Dec 12, 2011
Posts: 15
Santhosh,

What version of jboss you are using ? Adding the below entries in server/{profile}/conf/jboss-log4j.xml should be good enough.



Is this file BFS.log getting created or is it not at all getting created ?
Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 56
Thanks Ragav.

JBoss 5.1.0 (GA).

Yes, the BFS.log file has been created. But, the log goes to server.log (Root log file). BFS.log is always empty.

I have tried it. Still no log statements on BFS.log but in server.log.

 
wood burning stoves
 
subject: Log4j - log4j.properties configuration for separate logs and not on root logs.
 
Similar Threads
log4j - File Appenders..
How to call a Validator when the input-field is empty?
How to configure log4j.properties to log comments from mentioned packages only?
No logs from log4J on Server
thread safe logging in a servlet