Ejemplo n.º 1
0
        /// <summary>
        /// Set the logger to use File logging which is the only supported mechanism so far.
        /// </summary>
        void InitializeLogging()
        {
            Logger.Delegate = new LoggerDelegate(FileLogging.WriteEntry);

#if DEBUG
            MessageBox.Show(FileLogging.GenerateDefaultLogFileName(Constants.PRODUCT_NAME));
#endif
            Logger.WriteEntry(LogLevel.Information, "log file: " + FileLogging.GenerateDefaultLogFileName(Constants.PRODUCT_NAME) + " log level :" + Logger.currentLogLevel);
        }
Ejemplo n.º 2
0
        static public void WriteEntry(LogLevel level, String message)
        {
            try
            {
                if (Delegate != null && level >= currentLogLevel)
                {
                    StackTrace stackTrace = new StackTrace();
                    StackFrame stackFrame = stackTrace.GetFrame(1); //parent frame
                    MethodBase methodBase = stackFrame.GetMethod(); // who calls me.

                    Delegate("[ " + level + " ]" + methodBase.Name + ":" + message);
                }
            }

            catch (System.Exception ex)
            {
                FileLogging.WriteToEventLog("Application", ex.Message, System.Diagnostics.EventLogEntryType.Error);
            }
        }