File tree Expand file tree Collapse file tree
hotswap-agent-core/src/main Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ public class LogConfigurationHelper {
3939 public static final String DATETIME_FORMAT = "LOGGER_DATETIME_FORMAT" ;
4040 private static final String LOGFILE = "LOGFILE" ;
4141 private static final String LOGFILE_APPEND = "LOGFILE.append" ;
42+ private static final String LOG_TO_CONSOLE = "LOG_TO_CONSOLE" ;
4243
4344 /**
4445 * Search properties for prefix LOGGER and set level for package in format:
@@ -75,6 +76,8 @@ public static void configureLog(Properties properties) {
7576 LOGGER .error ("Invalid configuration property {} value '{}'. Unable to create/open the file." ,
7677 e , LOGFILE , logfile );
7778 }
79+ } else if (property .equals (LOG_TO_CONSOLE )) {
80+ AgentLogger .getHandler ().setLogToConsole (parseBoolean (properties .getProperty (LOG_TO_CONSOLE , "true" )));
7881 }
7982 }
8083 }
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public class AgentLoggerHandler {
3333
3434 // stream to receive the log
3535 PrintStream outputStream ;
36+ private boolean logToConsole = true ;
3637
3738 SimpleDateFormat sdf = new SimpleDateFormat ("HH:mm:ss.SSS" );
3839
@@ -45,10 +46,20 @@ public void setPrintStream(PrintStream outputStream) {
4546 this .outputStream = outputStream ;
4647 }
4748
49+ public void setLogToConsole (boolean logToConsole ) {
50+ this .logToConsole = logToConsole ;
51+ }
52+
53+ public boolean isLogToConsole () {
54+ return logToConsole ;
55+ }
56+
4857 // print a message to System.out and optionally to custom stream
4958 protected void printMessage (String message ) {
5059 String log = "HOTSWAP AGENT: " + sdf .format (new Date ()) + " " + message ;
51- System .out .println (log );
60+ if (logToConsole ) {
61+ System .out .println (log );
62+ }
5263 if (outputStream != null )
5364 outputStream .println (log );
5465 }
Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ LOGGER=info
8080# Print output into logfile (with choice to append - false by default)
8181# LOGFILE=agent.log
8282# LOGFILE.append=true
83+ # Print output to the console (true by default)
84+ # LOG_TO_CONSOLE=true
8385
8486# Comma separated list of class loaders to exclude from initialization, in the form of RegEx patterns.
8587# excludedClassLoaderPatterns=jdk.nashorn.*
You can’t perform that action at this time.
0 commit comments