0

My application uses log4cplus for logging.

When I launch it in CMD or PowerShell, logging is ok, line by line.

I decided to add small filtering function in PS, to make the output colorful.

# Simplified version
function ColoredOutput
{
    process { Write-Host $_ -ForegroundColor Yellow }
}

After this I launch the app as following:

myapp.exe | ColoredOutput

The problem is that now I get log messages in chunks for about several messages at a time, not line by line. I cannot understand what triggers the actual output.

Looks to me like some buffering of the output. Any ideas?

UPD: The problem seems to be related to some messages logged using simple std::cout in C++ instead of the logger.

UPD2: I start thinking that it's actually C++ that triggers the output. As you can see from the image below, the last message is from std::cout, all the previous - from log4cplus. example output

Werolik
  • 923
  • 1
  • 9
  • 23

1 Answers1

2

Found it. As it appeared, indeed it was log4cplus, which was buffering. Adding the following to the config helps:

log4cplus.appender.STDOUT.ImmediateFlush=true

Thanks to the interested, sorry for bothering.

Werolik
  • 923
  • 1
  • 9
  • 23