• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to filter out application specific log from server.log

 
saravanan periasamy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



Thanks in advance,
Saravanan
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your log4j configuration file look like and where is it placed?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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):

 
Varun Sharmas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Any help would be appreciated.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varun, welcome to Java Ranch!

Please read this: http://faq.javaranch.com/java/TellTheDetails

If you don't tell us the details all we can say is you did something wrong.

Have you looked at the example I mentioned for JBoss in Action, chapter 2?
 
Varun Sharmas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:Varun, welcome to Java Ranch!

Please read this: http://faq.javaranch.com/java/TellTheDetails

If you don't tell us the details all we can say is you did something wrong.

Have you looked at the example I mentioned for JBoss in Action, chapter 2?


Hi Peter.. thanks for the prompt response..

Here is my config and code..

private Logger logger = LogFactory.customLogger("abcdefgh");// gives me an instance of a sl4j logger instance

<appender name="ABCDEF" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="${jboss.server.log.dir}/ABCDEFGHIJKL.log"/>
<param name="MaxFileSize" value="5MB"/>
<param name="MaxBackupIndex" value="5"/>
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d][%t] [%c{1}] [%p] %m%n"/>
</layout>
</appender>

<category name="abcdefgh" additivity="false">
<appender-ref ref="ABCDEF" />
</category>

<root>
<priority value="INFO"/>
<appender-ref ref="FILE"/>
</root>

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.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic