File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -129,17 +129,25 @@ static void ConfigureLogging(Arguments arguments)
129
129
{
130
130
try
131
131
{
132
- Directory . CreateDirectory ( Path . GetDirectoryName ( arguments . LogFilePath ) ) ;
133
- if ( File . Exists ( arguments . LogFilePath ) )
132
+ var logFileFullPath = Path . GetFullPath ( arguments . LogFilePath ) ;
133
+ var logFile = new FileInfo ( logFileFullPath ) ;
134
+
135
+ if ( logFile . Directory != null && ! logFile . Directory . Exists )
136
+ // TODO: This should probably be done recursively. @asbjornu
137
+ logFile . Directory . Create ( ) ;
138
+
139
+ if ( ! logFile . Exists )
134
140
{
135
- using ( File . CreateText ( arguments . LogFilePath ) ) { }
141
+ using ( logFile . CreateText ( ) )
142
+ {
143
+ }
136
144
}
137
145
138
146
writeActions . Add ( x => WriteLogEntry ( arguments , x ) ) ;
139
147
}
140
148
catch ( Exception ex )
141
149
{
142
- Console . WriteLine ( "Failed to configure logging: " + ex . Message ) ;
150
+ Console . WriteLine ( "Failed to configure logging for '{0}': {1}" , arguments . LogFilePath , ex . Message ) ;
143
151
}
144
152
}
145
153
You can’t perform that action at this time.
0 commit comments