简体   繁体   中英

Log4j sorting logs

I am running one jar on unix machine and takes output of it on windows machine program using JSCH. So, i am creating log file on unix machine this will be detailed log file of jar present on unix.So, here i want to print some restricted output on unix console and take it on my windows application after executing the JAR file and all other info will go into detailed log file.So how i will print restricted output on console using log4j? what i need to do to achieve this? can anybody gives example of this?

You have to configure 2 different "appenders": a ConsoleAppender and a FileAppender, then you can direct output to one of them or both. To select which appender will receive a log item you can discriminate on logging priority (for example console could receive only ERROR and FATAL items, the log file could receive everything) and/or the class or package producing that log item. The log4j intro documentation page explains how to make this configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM