Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

java - Is it possible to configure log4j to create a new file with every run of the application?

For example, the first time I run an application (or immediately after I clear out the /logs directory), I want log4j to write the application's logs to a file called log.0. Then, I exit the application and restart it, I want the logs to be written to log.1. And so on.

I would like to keep this in the configuration file, although if I can't, I guess I could always do it in my application, when log4j is set up.

Is this possible? If so, how?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

May be this is what you are looking for

http://veerasundar.com/blog/2009/08/how-to-create-a-new-log-file-for-each-time-the-application-runs/

**Edit:**I got one more solution! But no idea whether it works or not,but you can try http://www.mail-archive.com/[email protected]/msg02132.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...