質問編集履歴
1
該当のソースコードを追加
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -29,7 +29,25 @@
|
|
|
29
29
|
### 該当のソースコード
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
+
public static synchronized void logConfig(String logFilePath) throws IOException {
|
|
33
|
+
if (fh != null) {
|
|
34
|
+
logger.removeHandler(fh);
|
|
35
|
+
fh.close();
|
|
32
|
-
|
|
36
|
+
fh = null;
|
|
37
|
+
}
|
|
38
|
+
fh = new FileHandler(logFilePath, true);
|
|
39
|
+
fh.setFormatter(new SimpleFormatter());
|
|
40
|
+
logger.addHandler(fh);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static void logMessage(String message) {
|
|
44
|
+
logger.info(message);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public static void main(String[] args) throws Exception {
|
|
48
|
+
FileLogger.logConfig(logFilePath); // logFilePathにはログファイルパスを格納
|
|
49
|
+
FileLogger.logMessage(param); // paramにはログファイルに出力する文字列を格納
|
|
50
|
+
}
|
|
33
51
|
```
|
|
34
52
|
|
|
35
53
|
### 試したこと・調べたこと
|