• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic