forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.xml
692 lines (579 loc) · 40.5 KB
/
Log.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
<Type Name="Log" FullName="Microsoft.VisualBasic.Logging.Log">
<TypeSignature Language="C#" Value="public class Log" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit Log extends System.Object" />
<TypeSignature Language="DocId" Value="T:Microsoft.VisualBasic.Logging.Log" />
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides a property and methods for writing event and exception information to the application's log listeners.</summary>
<remarks>
<format type="text/markdown"><]'s logging services. The `WriteEntry` and `WriteException` methods write messages to the application's log listeners. The listeners can be configured by the application's configuration file. For more information, see [Walkthrough: Changing Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-changing-where-my-application-log-writes-information.md) and [Working with Application Logs](~/docs/visual-basic/developing-apps/programming/log-info/working-with-application-logs.md).
The `My.Application.Log` object is available only for client applications. For Web applications, use `My.Log`. For more information, see <xref:Microsoft.VisualBasic.Logging.AspLog>.
The following table lists examples of tasks involving the `My.Application.Log` object.
|To|See|
|--------|---------|
|Write event information to the application's log listeners|[How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md)|
|Write exception information to the application's log listeners|[How to: Log Exceptions](~/docs/visual-basic/developing-apps/programming/log-info/how-to-log-exceptions.md)|
|Determine where `My.Application.Log` writes information|[Walkthrough: Determining Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-determining-where-my-application-log-writes-information.md)|
## Examples
This example shows how to use the `My.Application.Log.WriteEntry` method to log tracing information. For more information, see [How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md).
[!code-vb[VbVbalrMyApplicationLog#11](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyApplicationLog/VB/Form1.vb#11)]
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Log ();" />
<MemberSignature Language="ILAsm" Value=".method public specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.#ctor" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:Microsoft.VisualBasic.Logging.Log" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Log (string name);" />
<MemberSignature Language="ILAsm" Value=".method public specialname rtspecialname instance void .ctor(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.#ctor(System.String)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="name" Type="System.String" />
</Parameters>
<Docs>
<param name="name">
<see cref="T:System.String" />. The name to give to the <see cref="P:Microsoft.VisualBasic.Logging.Log.TraceSource" /> property object.</param>
<summary>Initializes a new instance of the <see cref="T:Microsoft.VisualBasic.Logging.Log" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="DefaultFileLogWriter">
<MemberSignature Language="C#" Value="public Microsoft.VisualBasic.Logging.FileLogTraceListener DefaultFileLogWriter { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class Microsoft.VisualBasic.Logging.FileLogTraceListener DefaultFileLogWriter" />
<MemberSignature Language="DocId" Value="P:Microsoft.VisualBasic.Logging.Log.DefaultFileLogWriter" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>get: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>Microsoft.VisualBasic.Logging.FileLogTraceListener</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the file the <see cref="T:Microsoft.VisualBasic.Logging.FileLogTraceListener" /> object that underlies the <see langword="Log" /> object.</summary>
<value>Returns the <see cref="T:Microsoft.VisualBasic.Logging.FileLogTraceListener" /> object that underlies the <see langword="Log" /> object.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use this property to determine the current configuration of the <xref:Microsoft.VisualBasic.Logging.FileLogTraceListener> object.
In client applications, the `Log` object is available through the `My.Application.Log` object. In Web applications, the `Log` object is available through the `My.Log` object.
]]></format>
</remarks>
<permission cref="T:System.Security.Permissions.FileIOPermission">Controls the ability to access files and folders. Associated enumeration: <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
</Docs>
</Member>
<Member MemberName="InitializeWithDefaultsSinceNoConfigExists">
<MemberSignature Language="C#" Value="protected virtual void InitializeWithDefaultsSinceNoConfigExists ();" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblynewslot virtual instance void InitializeWithDefaultsSinceNoConfigExists() cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.InitializeWithDefaultsSinceNoConfigExists" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Creates a new <see cref="T:Microsoft.VisualBasic.Logging.FileLogTraceListener" /> object and adds it to the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method creates a new <xref:Microsoft.VisualBasic.Logging.FileLogTraceListener>, sets its name to `FileLog`, and configures it to log messages with severity level <xref:System.Diagnostics.SourceLevels.Information> and greater. The new <xref:Microsoft.VisualBasic.Logging.FileLogTraceListener> object is then added to the <xref:System.Diagnostics.TraceSource.Listeners%2A> collection.
The <xref:Microsoft.VisualBasic.Logging.Log.%23ctor%2A> calls the method if the <xref:Microsoft.VisualBasic.Logging.Log.TraceSource%2A> property has not been configured. The trace source can be configured in the application's configuration file.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="TraceSource">
<MemberSignature Language="C#" Value="public System.Diagnostics.TraceSource TraceSource { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Diagnostics.TraceSource TraceSource" />
<MemberSignature Language="DocId" Value="P:Microsoft.VisualBasic.Logging.Log.TraceSource" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Diagnostics.TraceSource</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets to the <see cref="T:System.Diagnostics.TraceSource" /> object that underlies the <see langword="Log" /> object.</summary>
<value>Returns the <see cref="T:System.Diagnostics.TraceSource" /> object that underlies the <see langword="Log" /> object.</value>
<remarks>
<format type="text/markdown"><|
## Availability by Project Type
|Project type|Available|
|------------------|---------------|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|**Yes**|
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="WriteEntry">
<MemberSignature Language="C#" Value="public void WriteEntry (string message);" />
<MemberSignature Language="ILAsm" Value=".method public instance void WriteEntry(string message) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.WriteEntry(System.String)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="message" Type="System.String" />
</Parameters>
<Docs>
<param name="message">Required. The message to log. If <c>message</c> is <see langword="Nothing" />, an empty string is used.</param>
<summary>Writes a message to the application's log listeners.</summary>
<remarks>
<format type="text/markdown"><. You can change default log listeners. For more information, see [Working with Application Logs](~/docs/visual-basic/developing-apps/programming/log-info/working-with-application-logs.md).
For overloads that do not take the `id` argument, the `id` written to the log is defined by the following table.
|`severity`|Default `id`|
|----------------|------------------|
|<xref:System.Diagnostics.TraceEventType.Information>|0|
|<xref:System.Diagnostics.TraceEventType.Warning>|1|
|<xref:System.Diagnostics.TraceEventType.Error>|2|
|<xref:System.Diagnostics.TraceEventType.Critical>|3|
|<xref:System.Diagnostics.TraceEventType.Start>|4|
|<xref:System.Diagnostics.TraceEventType.Stop>|5|
|<xref:System.Diagnostics.TraceEventType.Suspend>|6|
|<xref:System.Diagnostics.TraceEventType.Resume>|7|
|<xref:System.Diagnostics.TraceEventType.Verbose>|8|
|<xref:System.Diagnostics.TraceEventType.Transfer>|9|
The following table lists examples of tasks involving the `WriteEntry` method.
|To|See|
|--------|---------|
|Write event information to the application's log listeners|[How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md)|
|Determine where `Log` writes information|[Walkthrough: Determining Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-determining-where-my-application-log-writes-information.md)|
## Availability by Project Type
|Project type|Available|
|------------------|---------------|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|**Yes**|
## Examples
This example shows how to use the `My.Application.Log.WriteEntry` method to log tracing information. For more information, see [How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md).
[!code-vb[VbVbalrMyApplicationLog#11](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyApplicationLog/VB/Form1.vb#11)]
This code example can run only within a client application. Change `My.Application.Log.WriteEntry` to `My.Log.WriteEntry` for Web applications.
]]></format>
</remarks>
<exception cref="T:System.Security.SecurityException">Code with partial trust calls the method, but writes to an event log listener that requires full trust.</exception>
<permission cref="T:System.Security.Permissions.FileIOPermission">Controls the ability to access files and folders. Associated enumeration: <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
</Docs>
</Member>
<Member MemberName="WriteEntry">
<MemberSignature Language="C#" Value="public void WriteEntry (string message, System.Diagnostics.TraceEventType severity);" />
<MemberSignature Language="ILAsm" Value=".method public instance void WriteEntry(string message, valuetype System.Diagnostics.TraceEventType severity) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.WriteEntry(System.String,System.Diagnostics.TraceEventType)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="message" Type="System.String" />
<Parameter Name="severity" Type="System.Diagnostics.TraceEventType" />
</Parameters>
<Docs>
<param name="message">Required. The message to log. If <c>message</c> is <see langword="Nothing" />, an empty string is used.</param>
<param name="severity">The type of message. By default, <see langword="TraceEventType.Information" />.</param>
<summary>Writes a message to the application's log listeners.</summary>
<remarks>
<format type="text/markdown"><. You can change default log listeners. For more information, see [Working with Application Logs](~/docs/visual-basic/developing-apps/programming/log-info/working-with-application-logs.md).
For overloads that do not take the `id` argument, the `id` written to the log is defined by the following table.
|`severity`|Default `id`|
|----------------|------------------|
|<xref:System.Diagnostics.TraceEventType.Information>|0|
|<xref:System.Diagnostics.TraceEventType.Warning>|1|
|<xref:System.Diagnostics.TraceEventType.Error>|2|
|<xref:System.Diagnostics.TraceEventType.Critical>|3|
|<xref:System.Diagnostics.TraceEventType.Start>|4|
|<xref:System.Diagnostics.TraceEventType.Stop>|5|
|<xref:System.Diagnostics.TraceEventType.Suspend>|6|
|<xref:System.Diagnostics.TraceEventType.Resume>|7|
|<xref:System.Diagnostics.TraceEventType.Verbose>|8|
|<xref:System.Diagnostics.TraceEventType.Transfer>|9|
The following table lists examples of tasks involving the `WriteEntry` method.
|To|See|
|--------|---------|
|Write event information to the application's log listeners|[How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md)|
|Determine where `Log` writes information|[Walkthrough: Determining Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-determining-where-my-application-log-writes-information.md)|
## Availability by Project Type
|Project type|Available|
|------------------|---------------|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|**Yes**|
## Examples
This example shows how to use the `My.Application.Log.WriteEntry` method to log tracing information. For more information, see [How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md).
[!code-vb[VbVbalrMyApplicationLog#11](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyApplicationLog/VB/Form1.vb#11)]
This code example can run only within a client application. Change `My.Application.Log.WriteEntry` to `My.Log.WriteEntry` for Web applications.
]]></format>
</remarks>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The message type is not one of the <see cref="T:System.Diagnostics.TraceEventType" /> enumeration values.</exception>
<exception cref="T:System.Security.SecurityException">Code with partial trust calls the method, but writes to an event log listener that requires full trust.</exception>
<permission cref="T:System.Security.Permissions.FileIOPermission">Controls the ability to access files and folders. Associated enumeration: <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
</Docs>
</Member>
<Member MemberName="WriteEntry">
<MemberSignature Language="C#" Value="public void WriteEntry (string message, System.Diagnostics.TraceEventType severity, int id);" />
<MemberSignature Language="ILAsm" Value=".method public instance void WriteEntry(string message, valuetype System.Diagnostics.TraceEventType severity, int32 id) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.WriteEntry(System.String,System.Diagnostics.TraceEventType,System.Int32)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="message" Type="System.String" />
<Parameter Name="severity" Type="System.Diagnostics.TraceEventType" />
<Parameter Name="id" Type="System.Int32" />
</Parameters>
<Docs>
<param name="message">Required. The message to log. If <c>message</c> is <see langword="Nothing" />, an empty string is used.</param>
<param name="severity">The type of message. By default, <see langword="TraceEventType.Information" />.</param>
<param name="id">Message identifier, typically used for correlation. By default, related to <c>entryType</c> as described in the table.</param>
<summary>Writes a message to the application's log listeners.</summary>
<remarks>
<format type="text/markdown"><. You can change default log listeners. For more information, see [Working with Application Logs](~/docs/visual-basic/developing-apps/programming/log-info/working-with-application-logs.md).
For overloads that do not take the `id` argument, the `id` written to the log is defined by the following table.
|`severity`|Default `id`|
|----------------|------------------|
|<xref:System.Diagnostics.TraceEventType.Information>|0|
|<xref:System.Diagnostics.TraceEventType.Warning>|1|
|<xref:System.Diagnostics.TraceEventType.Error>|2|
|<xref:System.Diagnostics.TraceEventType.Critical>|3|
|<xref:System.Diagnostics.TraceEventType.Start>|4|
|<xref:System.Diagnostics.TraceEventType.Stop>|5|
|<xref:System.Diagnostics.TraceEventType.Suspend>|6|
|<xref:System.Diagnostics.TraceEventType.Resume>|7|
|<xref:System.Diagnostics.TraceEventType.Verbose>|8|
|<xref:System.Diagnostics.TraceEventType.Transfer>|9|
The following table lists examples of tasks involving the `WriteEntry` method.
|To|See|
|--------|---------|
|Write event information to the application's log listeners|[How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md)|
|Determine where `Log` writes information|[Walkthrough: Determining Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-determining-where-my-application-log-writes-information.md)|
## Availability by Project Type
|Project type|Available|
|------------------|---------------|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|**Yes**|
## Examples
This example shows how to use the `My.Application.Log.WriteEntry` method to log tracing information. For more information, see [How to: Write Log Messages](~/docs/visual-basic/developing-apps/programming/log-info/how-to-write-log-messages.md).
[!code-vb[VbVbalrMyApplicationLog#11](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyApplicationLog/VB/Form1.vb#11)]
This code example can run only within a client application. Change `My.Application.Log.WriteEntry` to `My.Log.WriteEntry` for Web applications.
]]></format>
</remarks>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The message type is not one of the <see cref="T:System.Diagnostics.TraceEventType" /> enumeration values.</exception>
<exception cref="T:System.Security.SecurityException">Code with partial trust calls the method, but writes to an event log listener that requires full trust.</exception>
<permission cref="T:System.Security.Permissions.FileIOPermission">Controls the ability to access files and folders. Associated enumeration: <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
</Docs>
</Member>
<Member MemberName="WriteException">
<MemberSignature Language="C#" Value="public void WriteException (Exception ex);" />
<MemberSignature Language="ILAsm" Value=".method public instance void WriteException(class System.Exception ex) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.WriteException(System.Exception)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="ex" Type="System.Exception" />
</Parameters>
<Docs>
<param name="ex">Required. Exception to log.</param>
<summary>Writes exception information to the application's log listeners.</summary>
<remarks>
<format type="text/markdown"><. You can change default log listeners. For more information, see [Working with Application Logs](~/docs/visual-basic/developing-apps/programming/log-info/working-with-application-logs.md).
For overloads that do not take the `id` argument, the identifier written to the log is defined by the following table.
|`severity`|Default `id`|
|----------------|------------------|
|<xref:System.Diagnostics.TraceEventType.Information>|0|
|<xref:System.Diagnostics.TraceEventType.Warning>|1|
|<xref:System.Diagnostics.TraceEventType.Error>|2|
|<xref:System.Diagnostics.TraceEventType.Critical>|3|
|<xref:System.Diagnostics.TraceEventType.Start>|4|
|<xref:System.Diagnostics.TraceEventType.Stop>|5|
|<xref:System.Diagnostics.TraceEventType.Suspend>|6|
|<xref:System.Diagnostics.TraceEventType.Resume>|7|
|<xref:System.Diagnostics.TraceEventType.Verbose>|8|
|<xref:System.Diagnostics.TraceEventType.Transfer>|9|
The following table lists examples of tasks involving the `WriteException` method.
|To|See|
|--------|---------|
|Write exception information to the application's event log listeners.|[How to: Log Exceptions](~/docs/visual-basic/developing-apps/programming/log-info/how-to-log-exceptions.md)|
|Determine where `Log` writes information.|[Walkthrough: Determining Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-determining-where-my-application-log-writes-information.md)|
## Availability by Project Type
|Project type|Available|
|------------------|---------------|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|**Yes**|
## Examples
This example shows how to use the `My.Application.Log.WriteException` method to log exceptions. Uncomment the `Dim` and `MsgBox` lines to cause a <xref:System.NullReferenceException> exception. For more information, see [How to: Log Exceptions](~/docs/visual-basic/developing-apps/programming/log-info/how-to-log-exceptions.md).
[!code-vb[VbVbalrMyApplicationLog#10](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyApplicationLog/VB/Form1.vb#10)]
This code example can run only within a client application. Change `My.Application.Log.WriteException` to `My.Log.WriteException` for Web applications.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="ex" /> is <see langword="Nothing" />.</exception>
<exception cref="T:System.Security.SecurityException">Code with partial trust calls the method, but writes to an event log listener that requires full trust.</exception>
<permission cref="T:System.Security.Permissions.FileIOPermission">Controls the ability to access files and folders. Associated enumeration: <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
</Docs>
</Member>
<Member MemberName="WriteException">
<MemberSignature Language="C#" Value="public void WriteException (Exception ex, System.Diagnostics.TraceEventType severity, string additionalInfo);" />
<MemberSignature Language="ILAsm" Value=".method public instance void WriteException(class System.Exception ex, valuetype System.Diagnostics.TraceEventType severity, string additionalInfo) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.WriteException(System.Exception,System.Diagnostics.TraceEventType,System.String)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="ex" Type="System.Exception" />
<Parameter Name="severity" Type="System.Diagnostics.TraceEventType" />
<Parameter Name="additionalInfo" Type="System.String" />
</Parameters>
<Docs>
<param name="ex">Required. Exception to log.</param>
<param name="severity">The type of message. By default, <see cref="F:System.Diagnostics.TraceEventType.Error" />.</param>
<param name="additionalInfo">String to append to the message. By default, this is an empty string.</param>
<summary>Writes exception information to the application's log listeners.</summary>
<remarks>
<format type="text/markdown"><. You can change default log listeners. For more information, see [Working with Application Logs](~/docs/visual-basic/developing-apps/programming/log-info/working-with-application-logs.md).
For overloads that do not take the `id` argument, the identifier written to the log is defined by the following table.
|`severity`|Default `id`|
|----------------|------------------|
|<xref:System.Diagnostics.TraceEventType.Information>|0|
|<xref:System.Diagnostics.TraceEventType.Warning>|1|
|<xref:System.Diagnostics.TraceEventType.Error>|2|
|<xref:System.Diagnostics.TraceEventType.Critical>|3|
|<xref:System.Diagnostics.TraceEventType.Start>|4|
|<xref:System.Diagnostics.TraceEventType.Stop>|5|
|<xref:System.Diagnostics.TraceEventType.Suspend>|6|
|<xref:System.Diagnostics.TraceEventType.Resume>|7|
|<xref:System.Diagnostics.TraceEventType.Verbose>|8|
|<xref:System.Diagnostics.TraceEventType.Transfer>|9|
The following table lists examples of tasks involving the `WriteException` method.
|To|See|
|--------|---------|
|Write exception information to the application's event log listeners.|[How to: Log Exceptions](~/docs/visual-basic/developing-apps/programming/log-info/how-to-log-exceptions.md)|
|Determine where `Log` writes information.|[Walkthrough: Determining Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-determining-where-my-application-log-writes-information.md)|
## Availability by Project Type
|Project type|Available|
|------------------|---------------|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|**Yes**|
## Examples
This example shows how to use the `My.Application.Log.WriteException` method to log exceptions. Uncomment the `Dim` and `MsgBox` lines to cause a <xref:System.NullReferenceException> exception. For more information, see [How to: Log Exceptions](~/docs/visual-basic/developing-apps/programming/log-info/how-to-log-exceptions.md).
[!code-vb[VbVbalrMyApplicationLog#10](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyApplicationLog/VB/Form1.vb#10)]
This code example can run only within a client application. Change `My.Application.Log.WriteException` to `My.Log.WriteException` for Web applications.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="ex" /> is <see langword="Nothing" />.</exception>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The message type is not one of the <see cref="T:System.Diagnostics.TraceEventType" /> enumeration values.</exception>
<exception cref="T:System.Security.SecurityException">Code with partial trust calls the method, but writes to an event log listener that requires full trust.</exception>
<permission cref="T:System.Security.Permissions.FileIOPermission">Controls the ability to access files and folders. Associated enumeration: <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
</Docs>
</Member>
<Member MemberName="WriteException">
<MemberSignature Language="C#" Value="public void WriteException (Exception ex, System.Diagnostics.TraceEventType severity, string additionalInfo, int id);" />
<MemberSignature Language="ILAsm" Value=".method public instance void WriteException(class System.Exception ex, valuetype System.Diagnostics.TraceEventType severity, string additionalInfo, int32 id) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Logging.Log.WriteException(System.Exception,System.Diagnostics.TraceEventType,System.String,System.Int32)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="ex" Type="System.Exception" />
<Parameter Name="severity" Type="System.Diagnostics.TraceEventType" />
<Parameter Name="additionalInfo" Type="System.String" />
<Parameter Name="id" Type="System.Int32" />
</Parameters>
<Docs>
<param name="ex">Required. Exception to log.</param>
<param name="severity">The type of message. By default, <see cref="F:System.Diagnostics.TraceEventType.Error" />.</param>
<param name="additionalInfo">String to append to the message. By default, this is an empty string.</param>
<param name="id">Message identifier, typically used for correlation. By default, related to <c>entryType</c> as described in the table in the Remarks section.</param>
<summary>Writes exception information to the application's log listeners.</summary>
<remarks>
<format type="text/markdown"><. You can change default log listeners. For more information, see [Working with Application Logs](~/docs/visual-basic/developing-apps/programming/log-info/working-with-application-logs.md).
For overloads that do not take the `id` argument, the identifier written to the log is defined by the following table.
|`severity`|Default `id`|
|----------------|------------------|
|<xref:System.Diagnostics.TraceEventType.Information>|0|
|<xref:System.Diagnostics.TraceEventType.Warning>|1|
|<xref:System.Diagnostics.TraceEventType.Error>|2|
|<xref:System.Diagnostics.TraceEventType.Critical>|3|
|<xref:System.Diagnostics.TraceEventType.Start>|4|
|<xref:System.Diagnostics.TraceEventType.Stop>|5|
|<xref:System.Diagnostics.TraceEventType.Suspend>|6|
|<xref:System.Diagnostics.TraceEventType.Resume>|7|
|<xref:System.Diagnostics.TraceEventType.Verbose>|8|
|<xref:System.Diagnostics.TraceEventType.Transfer>|9|
The following table lists examples of tasks involving the `WriteException` method.
|To|See|
|--------|---------|
|Write exception information to the application's event log listeners.|[How to: Log Exceptions](~/docs/visual-basic/developing-apps/programming/log-info/how-to-log-exceptions.md)|
|Determine where `Log` writes information.|[Walkthrough: Determining Where My.Application.Log Writes Information](~/docs/visual-basic/developing-apps/programming/log-info/walkthrough-determining-where-my-application-log-writes-information.md)|
## Availability by Project Type
|Project type|Available|
|------------------|---------------|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|**Yes**|
## Examples
This example shows how to use the `My.Application.Log.WriteException` method to log exceptions. Uncomment the `Dim` and `MsgBox` lines to cause a <xref:System.NullReferenceException> exception. For more information, see [How to: Log Exceptions](~/docs/visual-basic/developing-apps/programming/log-info/how-to-log-exceptions.md).
[!code-vb[VbVbalrMyApplicationLog#10](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyApplicationLog/VB/Form1.vb#10)]
This code example can run only within a client application. Change `My.Application.Log.WriteException` to `My.Log.WriteException` for Web applications.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="ex" /> is <see langword="Nothing" />.</exception>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The message type is not one of the <see cref="T:System.Diagnostics.TraceEventType" /> enumeration values.</exception>
<exception cref="T:System.Security.SecurityException">Code with partial trust calls the method, but writes to an event log listener that requires full trust.</exception>
<permission cref="T:System.Security.Permissions.FileIOPermission">Controls the ability to access files and folders. Associated enumeration: <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
</Docs>
</Member>
</Members>
</Type>