Exemplo n.º 1
0
        public static void LogWarning(string interchangeId, string message, Exception exception)
        {
            PropertiesCollectionEx logProperties = new PropertiesCollectionEx();

            logProperties.Set("BTS.InterchangeID", interchangeId);
            Instance.logger.Warn(logProperties, message, exception);
        }
Exemplo n.º 2
0
        public static void LogMessage(string interchangeId, string message)
        {
            PropertiesCollectionEx logProperties = new PropertiesCollectionEx();

            logProperties.Set("BTS.InterchangeID", interchangeId);
            Instance.logger.Debug(logProperties, message);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Note - a registry key must exist under hklm/software for this string below
            string domain = "log4net.Ext.Serializable.UnitTest1.2.10";
            SLog   log    = (SLog)SLogManager.GetLogger(domain, typeof(TestSerializableLog));

            log.RegistryConfigurator();

            PropertiesCollectionEx props = new PropertiesCollectionEx();

            props.Set("TESTPROP", "myprop");

            log.InfoFormat(props, "Hello world with myprop for a prop {0}", log.GetHashCode());
            ((ILog)log).DebugFormat("Shouldn't see this - its a debug.");

            SLog log2 = (SLog)SLogManager.GetLogger(domain, typeof(TestSerializableLog));

            log2.Info("Hello world again - different SLog reference, same SLog?  Look for myprop prop " +  +log2.GetHashCode());

            MemoryStream  stream    = new MemoryStream();
            SoapFormatter formatter = new SoapFormatter();

            formatter.Serialize(stream, log);
            formatter.Serialize(stream, props);
            System.Text.Encoding encoding = System.Text.Encoding.UTF8;
            string ser = encoding.GetString(stream.ToArray());

            //log.Info("log looks like: " + ser);

            stream.Seek(0, System.IO.SeekOrigin.Begin);
            SoapFormatter          formatter2 = new SoapFormatter();
            SLog                   log3       = (SLog)formatter2.Deserialize(stream);
            PropertiesCollectionEx props2     = (PropertiesCollectionEx)formatter2.Deserialize(stream);

            log3.Info(props2, "Hello world from deserialized stream.  Look for myprop prop. " +  +log3.GetHashCode());

            SLog log4 = (SLog)SLogManager.GetLogger(domain, typeof(TestSerializableLog));

            log4.Info("Hello world again - different SLog reference, same SLog?  Look for myprop prop. " + log4.GetHashCode());


            log4.Info(string.Format("Hash codes: {0} {1} {2} {3}", log.Logger.GetHashCode(),
                                    log2.Logger.GetHashCode(),
                                    log3.Logger.GetHashCode(),
                                    log4.Logger.GetHashCode()));

            Console.ReadLine();
        }