private static string SanitizeSdName(string sdName)
        {
            // sanitize the SD-NAME as per http://tools.ietf.org/html/rfc5424#section-6.3.3
            // SD-NAME         = 1*32PRINTUSASCII; except '=', SP, ']', %d34 (")

            return(PrintableAsciiSanitizer.Sanitize(sdName, 32, new byte[] { 0x5D, 0x22, 0x3D }));
        }
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            if (string.IsNullOrEmpty(Thread.CurrentThread.Name))
            {
                ThreadIdConverter.Converter.Format(writer, loggingEvent);
            }

            writer.Write(PrintableAsciiSanitizer.Sanitize(Thread.CurrentThread.Name, 48));
        }
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            _name = string.IsNullOrEmpty(_name) ? Process.GetCurrentProcess().ProcessName : _name;

            if (string.IsNullOrEmpty(_name))
            {
                _name = "-"; // the NILVALUE
            }

            writer.Write(PrintableAsciiSanitizer.Sanitize(_name, 48));
        }
Ejemplo n.º 4
0
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            _processId = string.IsNullOrEmpty(_processId) ? Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture) : _processId;

            if (string.IsNullOrEmpty(_processId))
            {
                _processId = "-"; // the NILVALUE
            }

            writer.Write(PrintableAsciiSanitizer.Sanitize(_processId, 48));
        }
Ejemplo n.º 5
0
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            string messageId = null;

            // pop the NDC
            log4net.Util.ThreadContextStack ndc = loggingEvent.LookupProperty("NDC") as log4net.Util.ThreadContextStack;
            if (ndc != null && ndc.Count > 0)
            {
                // the NDC represents a context stack, whose levels are separated by whitespace. we will use this as our MessageId.
                messageId = ndc.ToString();
            }

            if (string.IsNullOrEmpty(messageId))
            {
                messageId = "-"; // the NILVALUE
            }
            else
            {
                messageId = messageId.Replace(' ', '.'); // replace spaces with periods
            }

            writer.Write(PrintableAsciiSanitizer.Sanitize(messageId, 32));
        }
Ejemplo n.º 6
0
 override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
 {
     writer.Write(PrintableAsciiSanitizer.Sanitize(Environment.CommandLine, 255));
 }
Ejemplo n.º 7
0
 override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
 {
     writer.Write(PrintableAsciiSanitizer.Sanitize(GetLocalhostFqdn().ToUpperInvariant(), 255));
 }
Ejemplo n.º 8
0
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            var id = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture);

            writer.Write(PrintableAsciiSanitizer.Sanitize(id, 48));
        }