private void Start() { _infoButton.onClick.AddListener(() => { using (UnityContext.PushObject(this)) { _logger.Information("This is an info"); } }); var testLogger = _logger.ForContext(Constant.CATEGORY_NAME, "Test"); _warningButton.onClick.AddListener(() => testLogger.Warning("This is a warning")); _errorButton.onClick.AddListener(() => { try { throw new InvalidOperationException("Invalid stuff"); } catch (Exception e) { _logger.Error(e, "This is an error"); } }); _threadButton.onClick.AddListener(() => { var stopWatch = Stopwatch.StartNew(); ThreadPool.QueueUserWorkItem(state => { stopWatch.Stop(); using (UnityContext.PushObject(this)) { _logger.Information("Log from thread {Id}, Invoke took: {Elapsed}", Thread.CurrentThread.ManagedThreadId, stopWatch.Elapsed); } }); }); }