File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes How to create a log file for each program execution in jboss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to create a log file for each program execution in jboss" Watch "How to create a log file for each program execution in jboss" New topic
Author

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

baront hicham
Greenhorn

Joined: Mar 30, 2009
Posts: 4
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

Joined: May 14, 2008
Posts: 5779
    
    7

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.


JBoss In Action
Javid Jamae
Author
Ranch Hand

Joined: May 14, 2008
Posts: 198
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


Author: JBoss in Action, javidjamae.com, @javidjamae on Twitter
baront hicham
Greenhorn

Joined: Mar 30, 2009
Posts: 4
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

Joined: May 14, 2008
Posts: 5779
    
    7

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create a log file for each program execution in jboss
 
Similar Threads
connection to DB
How to record sound in a applet
abt log file
Java EXE files?
Does anyone show the Log in and Create Profile Sequence Diagrams TO SUN?