質問編集履歴

2

追加文章

2018/08/10 17:37

投稿

mercurian-teto
mercurian-teto

スコア75

test CHANGED
File without changes
test CHANGED
@@ -21,6 +21,12 @@
21
21
  一度ログアウトしてからイベントビューアーを確認しましたが、
22
22
 
23
23
  イベントログが追加されていませんでした。
24
+
25
+
26
+
27
+ AutoLogkプロパティもtrueになっていたので、イベントログが出力できるはずです。
28
+
29
+
24
30
 
25
31
  また、windowsの「サービス」を確認しましたが、
26
32
 

1

コード追加

2018/08/10 17:37

投稿

mercurian-teto
mercurian-teto

スコア75

test CHANGED
File without changes
test CHANGED
@@ -35,3 +35,73 @@
35
35
 
36
36
 
37
37
  イベントログが出力されない理由がわからないのですが、だれかご教授してくださいませんか。
38
+
39
+
40
+
41
+ ```
42
+
43
+ !service1.cs
44
+
45
+
46
+
47
+ using System;
48
+
49
+ using System.Collections.Generic;
50
+
51
+ using System.ComponentModel;
52
+
53
+ using System.Data;
54
+
55
+ using System.Diagnostics;
56
+
57
+ using System.Linq;
58
+
59
+ using System.ServiceProcess;
60
+
61
+ using System.Text;
62
+
63
+ using System.Threading.Tasks;
64
+
65
+
66
+
67
+ namespace service_rennsyuu1
68
+
69
+ {
70
+
71
+ public partial class Service1 : ServiceBase
72
+
73
+ {
74
+
75
+ public Service1()
76
+
77
+ {
78
+
79
+ InitializeComponent();
80
+
81
+ }
82
+
83
+
84
+
85
+ protected override void OnStart(string[] args)
86
+
87
+ {
88
+
89
+ this.EventLog.WriteEntry("hello world");
90
+
91
+ }
92
+
93
+
94
+
95
+ protected override void OnStop()
96
+
97
+ {
98
+
99
+ this.EventLog.WriteEntry("bye world");
100
+
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+ ```