The FileAppender does not automagically remove or compress white space.
It logs what you tell it to log. This small snippet:
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout = new SimpleLayout();
BasicConfigurator.Configure(consoleAppender);
string str = String.Format("[{0,-20}] [{1, -10}]", "hello", "world");
log.Debug(str);
log.DebugFormat(str);
produces the following output:
DEBUG - [hello ] [world ]
DEBUG - [hello ] [world ]
Are you sure whatever program you're opening the log file up in isn't
compressing the whitespace?
--- Bruce Riley <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to print some log messages containing spaces to a
> RollingLogFileAppender, and the white space is getting compacted.
> Basically, I'm logging a string by doing something like this in C#:
>
> string str = String.Format("{0,-20} {1, -10}", string1, string2);
>
> The log output has only one space between the two strings, rather
> than being padded out to 20 spaces as I was expecting. (I'm trying to
> print columns of information.)
>
> Is this something I can turn off? If it's helpful, I've attached my
> log4net configuration below.
>
> Thanks
> Bruce
>
> <log4net>
> <appender name="RollingLogFileAppender"
> type="log4net.Appender.RollingFileAppender">
> <param name="File" value="Service.log" />
> <param name="AppendToFile" value="true" />
> <param name="MaxSizeRollBackups" value="3" />
> <param name="MaximumFileSize" value="100000000" />
> <param name="RollingStyle" value="Size" />
> <param name="StaticLogFileName" value="true" />
> <layout type="log4net.Layout.PatternLayout">
> <param name="Header" value="[BEGIN LOG]\r\n" />
> <param name="Footer" value="[END LOG]\r\n" />
> <param name="ConversionPattern" value="%d [%t]
> %-5p - %m%n" />
> </layout>
> </appender>
>
> <root>
> <level value="INFO" />
> <appender-ref ref="RollingLogFileAppender"/>
> </root>
> </log4net>
>