How to filter out application specific log from server.log
saravanan periasamy
Greenhorn
Joined: Feb 06, 2005
Posts: 22
posted
0
Hi All,
I am using JBoss log setup for my application.I did configuration for my application to log data in separate file from <JBoss_Home>/config/jboss-log4j.xml by adding my FileAppender. But my application get stored in two files (my appliation log file and server.log file). I do not know how to avoid logging my application specific log data in <JBoss_Home>/log/server.log.
Peter Johnson wrote:Add an appender-ref entry to you category entry, like this example which come form JBoss in Action, chapter 2 (JBIA is the name of the appender):
Hi guys.. I am stuck in a similar kinda problem...
I want some application specific logging to be redirected to a particular log.
for this I created an instance of logger in my Java class with a certain category name.
The same category is present in the Jboss-log4j.xml.
Also I have defined an appender for the same.
But when the actual logging occurs, the logs are directed to the normal server.log, instead of the intended log file.
With this configuration.. all the logs are routed to the root logger and none of the logs are routed to my defined appender.
ALso I have defined other categries as well... but after adding this config all the category specefic logging is routed to the root logger instead of the respective appender of the category.
You are using sl4j? I wonder if that has any bearing on this. Could you post a log entry of two. Perhaps slf4j is logging to stdout, and log4j is capturing that and posting it to the root appender. (The config you gave looks fine to me, pretty much matches what I have.)
Varun Sharmas
Greenhorn
Joined: Jan 20, 2010
Posts: 3
posted
0
Peter Johnson wrote:You are using sl4j? I wonder if that has any bearing on this. Could you post a log entry of two. Perhaps slf4j is logging to stdout, and log4j is capturing that and posting it to the root appender. (The config you gave looks fine to me, pretty much matches what I have.)
hi Peter..
I got the problem and the solution..
We are using Jboss and Jboss clearly has log4j.jar in its lib folder.
As a result the users web application should not have log4j jar. If that jar is present, jboss issues errors while initialising log4j xml and is unable to initialise the appender.
As a result none of the appender is initialised and thus logging was not taking place.
The errors from log for your reference
2010-01-21 07:18:36,966 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.log4j.Appender" vari
able.
2010-01-21 07:18:36,966 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
2010-01-21 07:18:36,966 ERROR [STDERR] log4j:ERROR [WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader@10747b4
] whereas object of type
2010-01-21 07:18:37,039 ERROR [STDERR] log4j:ERROR "org.jboss.logging.appender.FileAppender" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoade
r@9505f].
2010-01-21 07:18:37,039 ERROR [STDERR] log4j:ERROR Could not instantiate appender named "FILE".
I assumed that you were editing the server/xxx/cong/jboss-log4j.xml file - you never said you had your own file (I would have guessed otherwise if you would have said you have a log4j.properties file). JBoss AS will ignore your local log4j.xml file, unless you follow the configuration that Jaikiran provided here:
http://community.jboss.org/message/198691#198691
Just reread your first post, saw this statement "I did configuration for my application to log data in separate file from <JBoss_Home>/config/jboss-log4j.xml by adding my FileAppender". I interpreted that to mean you edited the jboss-log4j.xml file to add a new file appender, not that you were using a separate log4.xml file. Rereading that sentence, it is ambiguous and could go either way.