We have this specific problem related to JBoss-4.0.1 and log4j (which comes inbuilt in JBoss).
I dont want JBoss's inbuilt log4j to do logging for me.
I want to make my own log4j.properties file and JBoss on the fly should lift the properties file and log accordingly to files and console for me.
I tried disabling JBoss's log4j logging. But am unable to do it.
If I try to run a stand-alone java program (without JBoss Server) with a log4j properties file, it works fine and logs accordingly as given in my properties file.
But, if I try to run my application (on JBoss), it is not taking my properties file, but it is taking JBoss's log4j.xml and logs accordingly.
I tried to customize the log4j.xml, even that dint work for me. Then, it logs lots and lots of stuff to the log file, which I give in the xml file.
I tried deleting all the log4j.xml files, wherever I found in the %JBOSS_HOME% folder and try to keep a log4j.properties file. But even then, JBoss is logging in the server.log file, without even recognising my properties file. Even though, there is no xml file, JBoss logs as if it is lifting all the properties from the xml.
Please give me a solution to my problem.
TIA,
Regards,
Prashanth Babu.
-
JBoss and log4j logging (15 messages)
- Posted by: Prashanth Babu
- Posted on: November 09 2004 00:55 EST
Threaded Messages (15)
- well by Alon Agmon on November 09 2004 04:39 EST
- jBoss log4j by Sergey Pomytkin on November 15 2004 15:44 EST
- Logging in a separate file for your application by Daniel Oliva Bianco on December 21 2004 12:01 EST
- JBoss and log4j logging by hittiok hittiok on January 19 2005 12:24 EST
- JBoss and log4j logging by Shrividya Krishnaswamy on April 07 2005 16:36 EDT
- JBoss and log4j logging by Dursun Kirkg??ze on April 09 2005 11:14 EDT
-
JBoss and log4j logging by Dursun Kirkg??ze on April 09 2005 11:45 EDT
- JBoss and log4j logging by James O'Brien on October 13 2005 01:16 EDT
- jboss AS & log4j issue by koti prasad on March 31 2006 03:27 EST
- JBoss and custom log4j logging by Sunita Asija on January 30 2007 01:13 EST
- JBoss and log4j logging by Shrividya Krishnaswamy on April 07 2005 16:36 EDT
- JBoss and log4j logging : Little more? by vijendra singh on December 19 2006 09:31 EST
- Re: JBoss and log4j logging : Little more? by s s on May 17 2007 10:34 EDT
- Re: JBoss and log4j logging by Inder Jeet Singh on July 19 2007 07:47 EDT
- Re: JBoss and log4j logging by Vidar HÃ¥kestad on August 06 2007 15:00 EDT
- Re: JBoss and log4j logging by Maty David on August 07 2007 03:58 EDT
-
well[ Go to top ]
- Posted by: Alon Agmon
- Posted on: November 09 2004 04:39 EST
- in response to Prashanth Babu
why r u trying to disable jboss's logging ?-
jboss's logging are very flexible , im running few applications on jboss each one has its own log file - some use the syslog appender some use the file appender
you can customize it to whatever you like ... -
jBoss log4j[ Go to top ]
- Posted by: Sergey Pomytkin
- Posted on: November 15 2004 15:44 EST
- in response to Prashanth Babu
you running application in same JVM with jBoss so you'll have to share log4j with it. simplest way - add your loggers/appenders to jBoss
bit more tricky – load your configuration in addition to jBoss programmatically from application -
Logging in a separate file for your application[ Go to top ]
- Posted by: Daniel Oliva Bianco
- Posted on: December 21 2004 12:01 EST
- in response to Prashanth Babu
Set your log4j.properties like this
log4j.category.com.yourpath.yourclass=, EventLogger
log4j.appender.EventLogger=org.apache.log4j.RollingFileAppender
log4j.appender.EventLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.EventLogger.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} -%m%n
log4j.appender.EventLogger.MaxFileSize=100KB
log4j.appender.EventLogger.MaxBackupIndex=1
log4j.appender.EventLogger.File=D:\\logs
your_app.log
log4j.appender.EventLogger.Append=true
Jboss continue logging in his folder, and you can put your log in another file -
JBoss and log4j logging[ Go to top ]
- Posted by: hittiok hittiok
- Posted on: January 19 2005 12:24 EST
- in response to Prashanth Babu
I am also having the same problem. I created separate log file for my application using log4j but instead of creating in the path i specified, its getting clubbed with Jboss log file & is getting displayed in Jboss' server.log than creating a separate log file. Wanted a quick response. -
JBoss and log4j logging[ Go to top ]
- Posted by: Shrividya Krishnaswamy
- Posted on: April 07 2005 16:36 EDT
- in response to hittiok hittiok
If you any of you had any success. Please let me know -
JBoss and log4j logging[ Go to top ]
- Posted by: Dursun Kirkg??ze
- Posted on: April 09 2005 11:14 EDT
- in response to Shrividya Krishnaswamy
I can send the solution, I use, to you, if you are still searching a solution.
Bye
Dursun -
JBoss and log4j logging[ Go to top ]
- Posted by: Dursun Kirkg??ze
- Posted on: April 09 2005 11:45 EDT
- in response to Shrividya Krishnaswamy
If you any of you had any success. Please let me know
My solution is:
Firstly, you edit the file log4j.xml under the directory conf depending on, which server you use.
Let's assume, we are using the default. Then we should edit ${jboss.home.dir}\server\default\conf\log4j.xml
Now we can define an appender for our application in such a way
<appender name="APPLICATIONNAME_FILE" class="org.apache.log4j.FileAppender">
<param name="File" value="${jboss.server.home.dir}/log/testlog.log" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyy HH:mm:ss}, %-6p %C:%M:%L %m %n" />
</layout>
</appender>
After defined the appender, we can now define our category(Logger)in such a way
<category name="at.infrasoft.kirkgoeze">
<priority value="INFO" />
<appender-ref ref="APPLICATIONNAME_FILE" />
</category>
After all this, now you should restart(or start) JBOSS Application Server.
And finally, you can use it in your EJB-application or Web-application.
...
Logger logger =Logger.getLogger("at.infrasoft.kirkgoeze");
logger.warn("TEST warn");
logger.info("TEST info");
logger.debug("TEST debug");
...
Bye -
JBoss and log4j logging[ Go to top ]
- Posted by: James O'Brien
- Posted on: October 13 2005 13:16 EDT
- in response to Dursun Kirkg??ze
This is very helpful - thanks.
Note on this - although jboss wiki says to do so, don't add to root logger if you don't want all messages.If you any of you had any success. Please let me know
My solution is:Firstly, you edit the file log4j.xml under the directory conf depending on, which server you use.Let's assume, we are using the default. Then we should edit ${jboss.home.dir}serverdefaultconflog4j.xmlNow we can define an appender for our application in such a way<appender name="APPLICATIONNAME_FILE" class="org.apache.log4j.FileAppender"> <param name="File" value="${jboss.server.home.dir}/log/testlog.log" /> <param name="Append" value="true" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{dd MMM yyy HH:mm:ss}, %-6p %C:%M:%L %m %n" /> </layout> </appender>After defined the appender, we can now define our category(Logger)in such a way <category name="at.infrasoft.kirkgoeze"> <priority value="INFO" /> <appender-ref ref="APPLICATIONNAME_FILE" /> </category>After all this, now you should restart(or start) JBOSS Application Server.And finally, you can use it in your EJB-application or Web-application....Logger logger =Logger.getLogger("at.infrasoft.kirkgoeze");logger.warn("TEST warn");logger.info("TEST info");logger.debug("TEST debug");...Bye -
jboss AS & log4j issue[ Go to top ]
- Posted by: koti prasad
- Posted on: March 31 2006 03:27 EST
- in response to Dursun Kirkg??ze
Hi All,
Iam trying to use log4j in myapp.war to write to my own application log.
when I put lo4j.jar in my application, Iam getting classloader exceptions in jboss console
when I take that out, complete logging ( jboss & myapp) are going into my own log file
when I commeneted all lines in mylog4j.properties & dont keep log4j jar in myapp, logging is going to server.log
I have my log4j.properties fiel in myapp\web-inf. I have tried with wiki logging help ny reanming log4j.xml & changing jboss-service.xml, but dint work
seems to be jboss as is not maintaining multiple log environments
I dont want to make much changes outside.
tried out to use a specific classloader in app.war
jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
myapp:loader=myapp.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
Please help me out -
JBoss and custom log4j logging[ Go to top ]
- Posted by: Sunita Asija
- Posted on: January 30 2007 13:13 EST
- in response to Dursun Kirkg??ze
We have a situation where we have our own custom logging package (extended from Apache's log4j classes). So if we modify JBoss' log4j.xml, our classes cannot be found. Any suggestions? Thanks -
JBoss and log4j logging : Little more?[ Go to top ]
- Posted by: vijendra singh
- Posted on: December 19 2006 09:31 EST
- in response to Prashanth Babu
I played with log4j upto a great extent. My required output was supposed to be my own logging mechanism in which i should be able to create userlog.log name kind of different file and logs sholud generate in specific format(name#action#parameter) so that i can read the data easily. I am able to do in some jboss locations as i am testing in many servers before deploying. By modifying in log4j.xml based on appenders(File/Console).But in my local system i am unabe to test it as here file appender is not working.I get a blanck log file but things get logged in server.log here i can't get selective data in selective format. I don't know, i am missing any configuration or jboss server is having any problem or log4j.jar is having prob. For this i repalced many log4j.jar one by one and even set the classpath accordingly.But no benefit. Can anyone guide me what can be the cause of this. Vijendra -
Re: JBoss and log4j logging : Little more?[ Go to top ]
- Posted by: s s
- Posted on: May 17 2007 10:34 EDT
- in response to vijendra singh
If you want your application specific logging configuration independent of JBoss configuration then you should seriously consider rolling out log4j RepositorySelector which provides a clean solution to this problem. Read this excellent article about RepositorySelector here: http://www.qos.ch/logging/sc.jsp Having read that you will see that you need to write a simple custom RepositorySelector that will configure log4j LogManager. You could either do this as part of some init servlet or an JMX mbean or something appropriate. This is a cleaner way and will allow you to have multiple configuration coexist cleanly. JBoss seem to be aware of this and has decided to integrate a RepositorySelector integrated in JBoss 5. You can more details here: http://jira.jboss.com/jira/browse/JBAS-1313?page=history Hope this helps. -Sath -
Re: JBoss and log4j logging[ Go to top ]
- Posted by: Inder Jeet Singh
- Posted on: July 19 2007 07:47 EDT
- in response to Prashanth Babu
Problem in configuring log4j in Jboss Hi All, I am trying to set up a logger for my web application. I have Jboss 4.0.4 installed on my machine. I am using 'default' configuration of the JBoss server. I have added the follwoing code in my log4j.xml placed at /server/default/conf folder. Code: After doing this, i restarted the Jboss server and deployed my application on Jboss. When i run my application, the log file gets created but no messages are written to it. However all those messages appear in the 'server.log' frile of the Jboss. Can someone tell that what could be th -
Re: JBoss and log4j logging[ Go to top ]
- Posted by: Vidar HÃ¥kestad
- Posted on: August 06 2007 15:00 EDT
- in response to Inder Jeet Singh
Your java package structure (for the logged classes) begins with the package 'ppaslogs', as in ppaslogs.foo.bar, ppaslogs.bar.foo etc? Unless that is true, you will not have anything logged, I believe. -
Re: JBoss and log4j logging[ Go to top ]
- Posted by: Maty David
- Posted on: August 07 2007 03:58 EDT
- in response to Inder Jeet Singh
I Had the same issue, and i've finally found out that i had both log4j.jar and commons-logging.jar in my war file. those jars are already included in JBoss libraries. after solving this duplicity (i just removed those jars from my war) i had everything working ok.