I understand what you want to do now. I didn't look at this line
closley enough:

 log.Debug("%newline%newlineGun Level: " & Value & "%newline%newline")

That's not how log4net works. Patterns are evaulated once at start up
and cannot be dynmically inserted into a message. What do you expect to
happen in this case?

 log.Debug("%message");

Have you thought about implementing your own ILog that contains
additional logging levels? You could use log4net's unused Alert level
to signal an important event:

 log.Alert("Gun Level: " + Value)

The Alert level would know to print out newline sequences before and
after the message:

 public void Alert(object message) 
 {
  Logger.Log(
   ThisDeclaringType, 
   Level.Alert, 
   Environment.NewLine + message + Environment.NewLine, 
   null);
 }

There are a lot of ways to accomplish what you want. A quick hack would
be to extend PatternLayout and have it check for special values:

public class GunLevelPatternLayout : PatternLayout
{
 public override void Format(
  TextWriter writer, LoggingEvent loggingEvent)
 {
  string message = loggingEvent.MessageObject as string;
  if (message != null && 
      message.IndexOf("Gun Level:") >= 0)
  {
   writer.WriteLine();
   base.Format(writer, loggingEvent);
   writer.WriteLine();
  }
  else
  {
   base.Format(writer, loggingEvent);
  }
 }
}

While filters aren't necessarily designed for this, you might be able
to write a HighlightStringFilter:

 <filter type="HighlightStringMatchFilter">
  <regExToMatch value="hello" />
  <preHighlight value="&lt;strong&gt;" />
  <postHighlight value="&lt;/strong&gt;" />
 </filter>

that applies the pre and post values to part of a message when it
detects an Accept FilterDecision. Assuming you were logging your output
to some sort of HTML aware appender, the string "hello" would be
translated into
 
 <strong>hello</strong>

before it was written to the appender. 

I'll have to think about this more...

--- "Secules, Christopher T [AMSRD-AAR-AEF-A]"
<[EMAIL PROTECTED]> wrote:

> I just downloaded the latest version, but I just took another look at
> what
> you said.  I don't want this newline to be added to every line (I
> think that
> is what this configuration will do), I want it to be something that I
> can
> apply to log statements as needed.  For instance, I want to log
> statements
> as usual (one entry per line with timestamps), until I get to
> something that
> is important to the reader.  At that point, I want to add 1 or 2
> newlines
> before and after it, so that it stands out to the person reading the
> log.
> This, I believe, can only be done in code, right?  If 
> I put it in the XML config file, it will apply to the entire log.
> 
> The (message as Object) parameter of the methods to write to the log
> is
> usually a string, right?  Can't I just include an escape character in
> the
> message to signify the insertion of a newline?

Reply via email to