File tree Expand file tree Collapse file tree 4 files changed +61
-3
lines changed
Expand file tree Collapse file tree 4 files changed +61
-3
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . IO ;
23
34using Avalonia ;
45using Avalonia . ReactiveUI ;
56
7+ using log4net ;
8+ using log4net . Config ;
9+
610namespace SiteMonitor ;
711
812internal sealed class Program {
13+ /// <summary>
14+ /// The logger.
15+ /// </summary>
16+ private static readonly ILog LOG = LogManager . GetLogger ( typeof ( Program ) ) ;
17+
918 // Initialization code. Don't use any Avalonia, third-party APIs or any
1019 // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
1120 // yet and stuff might break.
1221 [ STAThread ]
1322 public static void Main ( string [ ] args ) {
23+ #if DEBUG
24+ XmlConfigurator . Configure ( new FileInfo ( "log4net.debug.config" ) ) ;
25+ #else
26+ XmlConfigurator . Configure ( new FileInfo ( "log4net.config" ) ) ;
27+ #endif
28+
29+ LOG . Info ( "Started application" ) ;
30+
31+ AppDomain . CurrentDomain . UnhandledException += ( _ , exceptArgs ) => {
32+ LOG . Fatal ( "Unhandled exception" , exceptArgs . ExceptionObject as Exception ) ;
33+ } ;
34+
1435 BuildAvaloniaApp ( )
1536 . StartWithClassicDesktopLifetime ( args ) ;
1637 }
Original file line number Diff line number Diff line change 22using System . Linq ;
33using System . Threading . Tasks ;
44
5+ using Avalonia ;
56using Avalonia . Controls ;
67using Avalonia . Interactivity ;
78
89using Microsoft . Extensions . DependencyInjection ;
910
1011using Nullinside . Api . Common . Desktop ;
11- #if ! DEBUG
12+ #if ! RELEASE
1213using Avalonia . Threading ;
1314
1415using SiteMonitor . ViewModels ;
@@ -72,12 +73,12 @@ protected override void OnInitialized() {
7273 if ( serverVersion . name ? . Equals ( Constants . APP_VERSION , StringComparison . InvariantCultureIgnoreCase ) ?? true ) {
7374// Had to add this because code clean up tools were removing the "redundant" return statement.
7475// which was causing the check to always be ignored.
75- #if ! DEBUG
76+ #if ! RELEASE
7677 return ;
7778#endif
7879 }
7980
80- #if ! DEBUG
81+ #if ! RELEASE
8182 var vm = ServiceProvider ? . GetRequiredService < NewVersionWindowViewModel > ( ) ;
8283 if ( null == vm ) {
8384 return ;
Original file line number Diff line number Diff line change 1+ <log4net>
2+ <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
3+ <layout type="log4net.Layout.PatternLayout">
4+ <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
5+ </layout>
6+ </appender>
7+ <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
8+ <file type="log4net.Util.PatternString" value="${AppData}\\nullinside\\twitch-streaming-tools\\log.txt"/>
9+ <appendToFile value="true"/>
10+ <rollingStyle value="Size"/>
11+ <maxSizeRollBackups value="5"/>
12+ <maximumFileSize value="10MB"/>
13+ <staticLogFileName value="true"/>
14+ <layout type="log4net.Layout.PatternLayout">
15+ <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
16+ </layout>
17+ </appender>
18+
19+ <root>
20+ <level value="INFO"/>
21+ <appender-ref ref="ConsoleAppender"/>
22+ <appender-ref ref="FileAppender"/>
23+ </root>
24+ </log4net>
Original file line number Diff line number Diff line change 1+ <log4net>
2+ <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
3+ <layout type="log4net.Layout.PatternLayout">
4+ <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
5+ </layout>
6+ </appender>
7+
8+ <root>
9+ <level value="DEBUG"/>
10+ <appender-ref ref="ConsoleAppender"/>
11+ </root>
12+ </log4net>
You can’t perform that action at this time.
0 commit comments