Log4j-寻找一个好的'入门'教程或博客[英] Log4j - Looking for a good 'Getting started' tutorial or blog

本文是小编为大家收集整理的关于Log4j-寻找一个好的'入门'教程或博客的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我今天下载了log4j版本1.2.16.我想在简单的Java控制台应用程序中启用登录.我正在寻找一个"快速启动"教程或博客,使我可以使用一些好的代码示例执行文件记录.

推荐答案

log4j的简短简介是一个非常好的起点对于log4j.

如果您准备花一些钱,可以购买 log4j手册 .

顺便说一句,如果您是新手登录Java,我建议您建议 slf4j + a> logback 组合.我认为,这是可用的最佳记录解决方案. SLF4J是登录的"立面",它需要下面的实现. Log4J和LogBack可以用作实现.

由于logback是log4j的继任者,并由同一作者制作,所以我建议使用它.不仅如此,登录手册可用在线 和免费.

由于log4j的开发或多或少停滞了,我建议您升级到slf4j + logback.

其他推荐答案

请查看此"如何将log4j与Java项目集成" 帮助您.它带您完成5个快速步骤.

  • 使用log4j
  • 设置项目
  • 创建log4j.properties文件
  • 写一个类以记录日志消息
  • 编译和运行程序
  • 检查日志消息

即使问题较早,您已经要求提供有关如何快速入门的教程或博客文章,但我考虑过分享.

本文地址:https://www.itbaoku.cn/post/1574804.html

问题描述

I 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.