示例#1
0
        /// <summary>
        /// Instance method to write an string in the event log.
        /// </summary>
        /// <param name="eventInfo">String to write in the event log.</param>
        protected virtual void WriteToEventLog(string eventInfo, EventLogEntryType eventLogEntryType)
        {
            Exception result;

            var appId = this.GetApplicationIdentity();

            AbstractLogger.TryWriteToEventLog(appId, eventInfo, eventLogEntryType, out result);
        }
        /// <summary>
        /// Write a warning to Unity event log
        /// </summary>
        /// <param name="info"></param>
        public static bool WriteWarningToEventLog(string info)
        {
            if (_applicationName == null)
            {
                _applicationName = GetApplicationName();
            }

            Exception resultException;

            var result = AbstractLogger.TryWriteToEventLog(_applicationName ?? string.Empty, info, EventLogEntryType.Warning, out resultException);

            return(result);
        }
示例#3
0
        /// <summary>
        /// Static method that tries to write an exception in the event log and return true or false in case of success or failure respectively. Result object contains the details of the exception
        /// trown during the process, null if it succeeds
        /// </summary>
        /// <param name="appId">The event log source. It has to be configured during the instalation. Otherwise the message will be logged against the default source
        /// provided by LogEventSourceProvider implementation</param>
        /// <param name="exception">An exeption to be logged. Construct string with messages and stack trace from the exception
        /// and all inner exceptions(message and stack trace included).</param>
        /// <param name="result">An object of type Exception with all exception thrown during the logging process.</param>
        /// <returns>True if the process succeeds, false otherwise. result object see result for details</returns>
        public static bool TryWriteExceptionToEventLog(string appId, Exception exception, out Exception result)
        {
            string builtMessage = LoggerManager.BuildExceptionStringRecursively(exception);

            return(AbstractLogger.TryWriteToEventLog(appId, builtMessage, EventLogEntryType.Error, out result));
        }