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 1
1
using System ;
2
+ using System . IO ;
2
3
3
4
using Avalonia ;
4
5
using Avalonia . ReactiveUI ;
5
6
7
+ using log4net ;
8
+ using log4net . Config ;
9
+
6
10
namespace SiteMonitor ;
7
11
8
12
internal sealed class Program {
13
+ /// <summary>
14
+ /// The logger.
15
+ /// </summary>
16
+ private static readonly ILog LOG = LogManager . GetLogger ( typeof ( Program ) ) ;
17
+
9
18
// Initialization code. Don't use any Avalonia, third-party APIs or any
10
19
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
11
20
// yet and stuff might break.
12
21
[ STAThread ]
13
22
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
+
14
35
BuildAvaloniaApp ( )
15
36
. StartWithClassicDesktopLifetime ( args ) ;
16
37
}
Original file line number Diff line number Diff line change 2
2
using System . Linq ;
3
3
using System . Threading . Tasks ;
4
4
5
+ using Avalonia ;
5
6
using Avalonia . Controls ;
6
7
using Avalonia . Interactivity ;
7
8
8
9
using Microsoft . Extensions . DependencyInjection ;
9
10
10
11
using Nullinside . Api . Common . Desktop ;
11
- #if ! DEBUG
12
+ #if ! RELEASE
12
13
using Avalonia . Threading ;
13
14
14
15
using SiteMonitor . ViewModels ;
@@ -72,12 +73,12 @@ protected override void OnInitialized() {
72
73
if ( serverVersion . name ? . Equals ( Constants . APP_VERSION , StringComparison . InvariantCultureIgnoreCase ) ?? true ) {
73
74
// Had to add this because code clean up tools were removing the "redundant" return statement.
74
75
// which was causing the check to always be ignored.
75
- #if ! DEBUG
76
+ #if ! RELEASE
76
77
return ;
77
78
#endif
78
79
}
79
80
80
- #if ! DEBUG
81
+ #if ! RELEASE
81
82
var vm = ServiceProvider ? . GetRequiredService < NewVersionWindowViewModel > ( ) ;
82
83
if ( null == vm ) {
83
84
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