Hello,
I want to do arbitrary binary data logging to the file.
After configuring a separate logger with config. given below
<appender name="RF2" class="RollingFileAppender">
<param name="File" value="c:/work/ptt/logs1/outputStrm.log" />
<param name="MaxFileSize" value="1000KB" />
<param name="MaxBackupIndex" value="100" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%m" />
</layout>
</appender>
<logger name="outputStrm" additivity="false">
<appender-ref ref="RF2" />
<level value="DEBUG" />
</logger>
I've done some test code:
(I use W2K and I won't use unicode for my current project)
std::string s;
s.resize(0xFF);
for (BYTE i = 0;i<0xFF;++i)
{
s[i]=i;
}
OUTPUTSTREAM->forcedLog(::log4cxx::Level::INFO, s);
So, after that, an output file was 256 bytes instead 255!!!
I found, that it is due to "Streams were originally designed for text, so the
default output mode is text. In text mode, the newline character (hexadecimal
10) expands to a carriage returnâlinefeed (16-bit only). " (from MSDN).
The question is: how to do such logging, without changing the original LOG4CXX
code?