예제 #1
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureLogging(logging =>
        {
            // clear default logging providers
            logging.ClearProviders();

            // add built-in providers manually, as needed
            logging.AddConsole();
            logging.AddDebug();
            logging.AddEventLog();
            logging.AddEventSourceLogger();
            System.Diagnostics.SourceSwitch sourceSwitchName = new System.Diagnostics.SourceSwitch("test");
            logging.AddTraceSource(sourceSwitchName);
        })
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup <Startup>();
        });
예제 #2
0
 public TraceSourceLoggerProvider(System.Diagnostics.SourceSwitch rootSourceSwitch, System.Diagnostics.TraceListener?rootTraceListener)
 {
 }
예제 #3
0
 public TraceSourceLoggerProvider(System.Diagnostics.SourceSwitch rootSourceSwitch)
 {
 }
예제 #4
0
 public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Diagnostics.SourceSwitch sourceSwitch, System.Diagnostics.TraceListener listener)
 {
     throw null;
 }
예제 #5
0
        /// <summary>
        /// Create trace sources containing multiple listeners with the multiple formats, source levels and fields.
        /// </summary>
        /// <param name="creationData">Creation data for TraceSources.</param>
        /// <param name="name">TraceSource name.</param>
        /// <returns>TraceSources containing listeners all sharing same format.</returns>
        private static ICollection<System.Diagnostics.TraceSource> CreateTraceSource(string name, IEnumerable<LogCreationDatum> creationData)
        {
            LinkedList<System.Diagnostics.TraceSource> tracesources = new LinkedList<System.Diagnostics.TraceSource>();
            foreach (LogCreationDatum creationDatum in creationData)
            {
                System.Diagnostics.TraceSource ts = new System.Diagnostics.TraceSource(name);
                Udbus.Core.Logging.Formatter formatter = new Udbus.Core.Logging.Formatter(creationDatum.format, creationDatum.fields);
                IEnumerable<System.Diagnostics.TraceListener> listeners = Udbus.Core.Logging.TraceListenerFormat.GenerateTraceListener(formatter, creationDatum.listeners);

                // Remove OutputDebug listener if not debugging.
            #if !DEBUG
            //#if !TRACE
                ts.Listeners.Remove("Default");
            //#endif // !TRACE
            #endif // !DEBUG

                // Add listeners.
                ts.Listeners.AddRange(listeners.ToArray());

                ts.Attributes.Add("autoflush", "true");
                ts.Attributes.Add("indentsize", "2");

                // See System.Diagnostics.SourceLevels.
                System.Diagnostics.SourceSwitch sourceSwitch = new System.Diagnostics.SourceSwitch(name, creationDatum.sourceLevel.ToString());
                ts.Switch = sourceSwitch;
                tracesources.AddLast(ts);
            }
            return tracesources;
        }