Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.
MIT License
1.14k stars 80 forks source link

AddZLoggerConsole doesn't write Visual Studio's output window on WPF Application #53

Closed longod closed 2 years ago

longod commented 2 years ago

It seems that ZLoggerConsoleLoggerProvideruses System.Console's stream.

https://github.com/Cysharp/ZLogger/blob/23e28e44537b97e77eeff5bee435fb54f0d11d9c/src/ZLogger/Providers/ZLoggerConsoleLoggerProvider.cs#L28

I tried to implement IAsyncLogProcessor using System.Diagnostics. It works. Such like as:

    using System.Threading.Tasks;
    using Microsoft.Extensions.Logging;
    using ZLogger;
    public class SimpleProcessor : IAsyncLogProcessor {
        private readonly ZLoggerOptions _options;
        public SimpleProcessor (ZLoggerOptions options) {
            _options = options;
        }
        public ValueTask DisposeAsync() {
            return default;
        }
        public void Post(IZLoggerEntry log) {
            try {
                var msg = log.FormatToString(_options, null);
                System.Diagnostics.Trace.WriteLine(msg);
            }
            finally {
                log.Return();
            }
        }
    }

Do you have any plans to support this on non custom processor?

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.