diff --git a/jps/jps-builders/src/defaultLogConfig.properties b/jps/jps-builders/src/defaultLogConfig.properties new file mode 100644 index 000000000000..96da517cc67f --- /dev/null +++ b/jps/jps-builders/src/defaultLogConfig.properties @@ -0,0 +1,13 @@ +log4j.rootLogger=info, file + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=$LOG_FILE_PATH$ +log4j.appender.file.MaxFileSize=20Mb +log4j.appender.file.MaxBackupIndex=20 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d [%7r] %6p - %30.30c - %m\n + +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.target=System.err +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%-5p %c{1} - %m%n diff --git a/jps/jps-builders/src/defaultLogConfig.xml b/jps/jps-builders/src/defaultLogConfig.xml deleted file mode 100644 index 98852758ecc5..000000000000 --- a/jps/jps-builders/src/defaultLogConfig.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java index 8829cd93bc0a..bd7303a9c5e5 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java @@ -27,11 +27,8 @@ import io.netty.handler.codec.protobuf.ProtobufDecoder; import io.netty.handler.codec.protobuf.ProtobufEncoder; import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender; -import io.netty.util.internal.logging.InternalLoggerFactory; -import io.netty.util.internal.logging.Log4JLoggerFactory; import org.apache.log4j.Level; -import org.apache.log4j.LogManager; -import org.apache.log4j.xml.DOMConfigurator; +import org.apache.log4j.PropertyConfigurator; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -61,9 +58,9 @@ public class BuildMain { private static final String PRELOAD_PROJECT_PATH = "preload.project.path"; private static final String PRELOAD_CONFIG_PATH = "preload.config.path"; - private static final String LOG_CONFIG_FILE_NAME = "build-log.xml"; + private static final String LOG_CONFIG_FILE_NAME = "build-log.properties"; private static final String LOG_FILE_NAME = "build.log"; - private static final String DEFAULT_LOGGER_CONFIG = "defaultLogConfig.xml"; + private static final String DEFAULT_LOGGER_CONFIG = "defaultLogConfig.properties"; private static final String LOG_FILE_MACRO = "$LOG_FILE_PATH$"; private static final Logger LOG; static { @@ -82,7 +79,10 @@ public class BuildMain { public static void main(String[] args){ final long processStart = System.currentTimeMillis(); - System.out.println("Build process started. Classpath: " + System.getProperty("java.class.path")); + final String startMessage = "Build process started. Classpath: " + System.getProperty("java.class.path"); + System.out.println(startMessage); + LOG.info(startMessage); + final String host = args[HOST_ARG]; final int port = Integer.parseInt(args[PORT_ARG]); final UUID sessionId = UUID.fromString(args[SESSION_ID_ARG]); @@ -90,12 +90,11 @@ public class BuildMain { final File systemDir = new File(FileUtil.toCanonicalPath(args[SYSTEM_DIR_ARG])); Utils.setSystemRoot(systemDir); - final long eventLoopStart = System.currentTimeMillis(); + final long connectStart = System.currentTimeMillis(); // IDEA-123132, let's try again for (int attempt = 0; attempt < 3; attempt++) { try { ourEventLoopGroup = new NioEventLoopGroup(1, SharedThreadPool.getInstance()); - System.out.println("Created event loop in " + attempt + " attempts for " + (System.currentTimeMillis() - eventLoopStart) + " ms"); break; } catch (IllegalStateException e) { @@ -115,7 +114,6 @@ public class BuildMain { } } - final long nettyBootstrapStart = System.currentTimeMillis(); final Bootstrap bootstrap = new Bootstrap().group(ourEventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer() { @Override protected void initChannel(Channel channel) throws Exception { @@ -127,15 +125,13 @@ public class BuildMain { } }).option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_KEEPALIVE, true); - final long nettyBootstrapEnd = System.currentTimeMillis(); - System.out.println("Netty bootstrap created in " + (nettyBootstrapEnd - nettyBootstrapStart) + " ms"); - final ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port)).awaitUninterruptibly(); - System.out.println("Connection to IDE established in " + (System.currentTimeMillis() - nettyBootstrapEnd) + " ms"); final boolean success = future.isSuccess(); if (success) { + LOG.info("Connection to IDE established in " + (System.currentTimeMillis() - connectStart) + " ms"); + final String projectPathToPreload = System.getProperty(PRELOAD_PROJECT_PATH, null); final String globalsPathToPreload = System.getProperty(PRELOAD_CONFIG_PATH, null); if (projectPathToPreload != null && globalsPathToPreload != null) { @@ -333,7 +329,6 @@ public class BuildMain { } private static void initLoggers() { - final long start = System.currentTimeMillis(); try { final String logDir = System.getProperty(GlobalOptions.LOG_DIR_OPTION, null); final File configFile = logDir != null? new File(logDir, LOG_CONFIG_FILE_NAME) : new File(LOG_CONFIG_FILE_NAME); @@ -341,8 +336,7 @@ public class BuildMain { String text = FileUtil.loadFile(configFile); final String logFile = logDir != null? new File(logDir, LOG_FILE_NAME).getAbsolutePath() : LOG_FILE_NAME; text = StringUtil.replace(text, LOG_FILE_MACRO, StringUtil.replace(logFile, "\\", "\\\\")); - new DOMConfigurator().doConfigure(new StringReader(text), LogManager.getLoggerRepository()); - System.out.println("BuildMain.initLoggers loggers configured in " + (System.currentTimeMillis() - start) + " ms"); + PropertyConfigurator.configure(new ByteArrayInputStream(text.getBytes("UTF-8"))); } catch (IOException e) { System.err.println("Failed to configure logging: "); @@ -351,8 +345,6 @@ public class BuildMain { } Logger.setFactory(MyLoggerFactory.class); - InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory()); - System.out.println("BuildMain.initLoggers finished in " + (System.currentTimeMillis() - start) + " ms"); } private static void ensureLogConfigExists(final File logConfig) throws IOException {