# HOW TO USE LOG4J WITHIN ECLIPSE IN 10 MINUTES
# by Daniel Gonzalez Gasull gasull[at]gmail[dot]com
#
# 1) Download log4j http://logging.apache.org/site/binindex.cgi
# 2) Unpack the .zip file in your Java folder (In Windows it is usually
# C:\Program Files\Java\)
# 3) In Eclipse: Window - Preferences... - Java - Build Path - User Libraries -
# New - write "log4j" - OK - Add JARs... - navigate to find your log4j .jar you just
# unpacked in the Java Folder - OK
# 4) right click on your project in the Package Explorer - New - Folder -
# in "Folder name" write "log4j" - click Advanced - select "Link to a folder in the
# file system" - create a new folder "log4j" in your project folder in the file system
# 5) Place this file you are reading right now in in the folder you just created. Name
# the file as log4j.properties
# 6) In Eclipse: Run - Run... - In the navigation bar on the left select either the
# server, or the runnable class, or the JUnit test you want to log with log4j -
# select the Classpath tab - User Entries - Advanced... - Add folders - OK - select
# the "log4j" folder you created in your project - OK
# 7) Repeat step 6 for other servers, runnable classes or JUnit tests you want to log
#
Change in the following line the "org.example.foo.bar" with whatever you want.
log4j.category.org.example.foo.bar=DEBUG
# 9) Add the following import to the Java Class you want to log:
# import org.apache.log4j.Logger;
# 10) Add this lines to the Java Class you want to log:
# /**
# * Log4j logger
# */
# static Logger log4j = Logger.getLogger("org.example.foo.bar");
# 11) Substitute in the code above "org.example.foo.bar" with whatever your wrote in
# in the step 8.
# 12) Add something like the following code in your Class whenever you want to log:
# log4j.debug("WTF?");
# 13) Repeat steps 9, 10, 11 and 12 for every Java Class you want to log
# 14) Enjoy!
log4j.rootCategory=DEBUG, R, O
# Stdout
log4j.appender.O=org.apache.log4j.ConsoleAppender
# File
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=log4j.log
# Control the maximum log file size
log4j.appender.R.MaxFileSize=100KB
# Archive log files (one backup file here)
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.O.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
log4j.appender.O.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
分享到:
相关推荐
然而,根据“how to use eclipse”这一标题,我将基于这一假设,提供Eclipse开发环境(IDE)的使用方法。 Eclipse是Java开发环境中广泛使用的一款集成开发工具,它是由Eclipse基金会维护的一个开源项目。Eclipse ...
You should ensure that the server's public keys are loaded by the client as described in How to use SFTP (with server validation - known hosts), or you may want to switch off server validation to get ...
How to use epoll A complete example in C How to use epoll A complete example in C How to use epoll A complete example in C How to use epoll A complete example in C
How to use projector
this article introduces how to use awk in linux
How to Use Objects Code and Concepts Holger Gast
How To Use Adobe Photoshop CS2 <br>Photoshop CS2使用指南 <br>By Daniel Giordan, Doug Nelson <br>Publisher: Sams Publishing <br>Have you ever looked at your color pictures and wished ...
How to use the Bayes Net Toolbox? This documentation was last updated on 29 October 2007.
How to use 256 Color Bitmaps in ImageList (Win32 SDK solution)如何在ImageList中使用256色的位图(Win32 SDK的解决方案)(5KB)
How to use HttpWebRequest and HttpWebResponsein _NET
This tutorial explains how to set up log4j with email, files and stdout. It compares XML to properties configuration files, shows how to change LogLevels for a running application. Furthermore, we ...
How to Use Objects will help you gain that understanding, so you can write code that works exceptionally well in the real world. Author Holger Gast focuses on the concepts that have repeatedly ...
how to use array in jaba
IBM How to use Seven Keys To Success.
Lists I- How to use lists in Excel 2003.xlt
Simple application that shows how to use the Data Control to connect to the Biblio.mdb database and display all authors in the Authors table.
HOW TO USE SDRAM ,sdr sdram的用户手册,比datasheet讲述的详细!
Lists I- How to use lists in Excel 2003(2).xlt
how to use spring validator