Q:

JMeter logging in console and log viewer simultaneously

Newbie question
Using JSR223 PostProcessor
How does one log to both at the same time?
Want to avoid duplicating messages.
out.println("WARNING")
log.warn("WARNING")

Have a ton of post processing scripts using log.warn and I need these messages to show up in console at the same time. Been searching like mad and cannot find anything about using one log to output to both. Maybe some way to make each log.warn into a out.println using a pre-processor?
Thanks

A:

Some options:
Print the message everytime the warn is logged:

use a method that makes both operations:
public static void printAndLog(Logger log, String message) {
    System.out.println(message)
    log.warn(message)
}

use aspects from AspectJ

Use 2 appenders in log4j (one for console, one for file)
This is applicable if logging a message to the console (STDOUT) is an accepted alternative to System.out.println.

adjust log4j.properties:
log4j.rootLogger=INFO,CONSOLE,FILE
log4j.appender.FILE=org.apache.log4j.FileAppender    
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 

adjust log4j2.xml
<Configuration status="INFO">
    <Appenders>
        <Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="%msg%n" />
        </Console>
        <File name="FILE" ...>
            <PatternLayout pattern="..."/>
        </File>
    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="CONSOLE" />
            <AppenderRef ref="FILE"/>
        </Root>
    </Loggers>
</Configuration>

