Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create a log file for each program execution in jboss

 
baront hicham
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have creat a program, but i would creat a log fil for each execution of this program, i dont know if possible or no, plaise help me
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
baront, welcome to Javas Ranch!

JBoss AS uses log4j to do its logging. The log4j config file is located at server/xxx/conf/jboss-log4j.xml. The log4j documentation is at http://logging.apache.org/log4j/1.2/manual.html.

What do you mean by "program execution in JBoss"? Once an app has been deployed to JBoss AS, it runs until either the app is undeployed or JBoss AS is brought down. Thus a "program execution" is usually the same as a run of JBoss AS, and each time JBoss AS runs it creates a new log file.
 
Javid Jamae
Author
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what you're looking for is to use multiple Log4j appenders. Here is one reference (there are many others on google) - http://www.jguru.com/faq/view.jsp?EID=1311014
 
baront hicham
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Peter and Javid

I change the file "server/xxx/conf/jboss-log4j.xml" to give me a log file of a package, but jboss creates one file for each minute, but I want a file for each execution, behold the little code I added to the file "server/xxx/conf/jboss-log4j.xml"

<logger name="package.subpackage">
<appender-ref ref="LOG_IOXML"/>
</logger>

<appender name="LOG_IOXML" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${jboss.server.log.dir}/file.log"/>
<param name="Append" value="false"/>
<param name="DatePattern" value="'.'yyyy-MM-dd-HH-mm"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm} %m%n"/>
</layout>
</appender>
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are getting a new log file each minute because that is how you configured it. The DatePattern defines the interval at which new logs are created, and since your DatePattern includes minutes, you get a new log file every minute. If you want a log file per run, use FileAppender instead. And by the way, you should be using the JBoss version of the appender: org.jboss.logging.appender.FileAppender
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic