Log4j - Looking for a good 'Getting started' tutorial or blog [closed]
开发者_运维问答
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionI downloaded Log4j version 1.2.16 today. I want to enable logging in a simple java console application. I'm looking for a 'quick start' tutorial or blog that allows me to perform file logging with some good code samples.
The short introduction to log4j is a perfectly fine starting point for log4j.
If you're ready to spend some money, you can buy the log4j manual.
By the way, if you're new to logging in Java, I'd suggest the slf4j + logback combo. In my opinion, this is the best logging solution available. Slf4j is a logging "facade" and it needs an implementation underneath. Log4j and logback can be used as implementations.
Since logback is log4j's successor and made by the same author, I'd suggest using it instead. Not only that, logback's manual is available online and it's free.
Since log4j's development has more or less stalled, I'd suggest you upgrade to slf4j + logback.
Please see whether this "How to integrate log4j with Java project" helps you. It takes you through 5 quick steps.
- Set up the project with log4j
- Create log4j.properties file
- Write a class to record log messages
- Compile and run program
- Check the log messages
Even though the question is older, as you have asked for a tutorial or a blog post on how to get started quickly, I thought of sharing this.
精彩评论