logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Khotyn Huang (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LOG4J2-965) Log4j2 cause System.out unable to work on windows
Date Mon, 02 Mar 2015 14:03:04 GMT
Khotyn Huang created LOG4J2-965:

             Summary: Log4j2 cause System.out unable to work on windows
                 Key: LOG4J2-965
                 URL: https://issues.apache.org/jira/browse/LOG4J2-965
             Project: Log4j 2
          Issue Type: Bug
    Affects Versions: 2.1
         Environment: Windows, with janis  in classpath
            Reporter: Khotyn Huang
            Priority: Critical

### Demonstration

The underlining project demonstrate the bug.

The project's build.gradle file:

apply plugin: 'java'

version = '1.0'

repositories {

def log4j2Version = '2.2'
def log4j2GroupId = "org.apache.logging.log4j"

dependencies {
    compile log4j2GroupId + ':log4j-core:' + log4j2Version
    compile log4j2GroupId + ":log4j-jcl:" + log4j2Version
    compile log4j2GroupId + ":log4j-slf4j-impl:" + log4j2Version
    compile 'org.fusesource.jansi:jansi:1.11'

A log4j2.xml in classpath:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
        <File name="root" fileName="${sys:user.home}/logs/windowsbug.log">
                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
        <Root level="info">
            <AppenderRef ref="root"/>

And the main class:

import org.slf4j.LoggerFactory;

 * @author khotyn 15/3/2 下午8:17
public class Log4j2WindowsBug {

    public static void main(String[] args) {
        System.out.println("Able to print on Windows");
        System.out.println("Unable to print on Windows");

The output of the demo is:

Able to print on Windows

The third line did not print to Windows console.

### Reason

It seems that log4j2 will wrapper System.out to WindowsAnsiOutputStream if jansi is available
in classpath. And in OutputStreamManager's close method, the wrapper WindowsAnsiOutputStream
is not considered, and cause the underling System.out closed.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message