Displaying Dicom.Network logging in FormControl TextBox

547 views
Skip to first unread message

David Wetelainen

unread,
Jun 10, 2016, 6:15:56 PM6/10/16
to Fellow Oak DICOM
I am able to direct FO logging to both a file and console target but am unable to direct Dicom.Network to a FormControl target. I can display regular NLog logs in the FormControl using this declaration:

Public Shared alogger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger()
 alogger.Log(NLog.LogLevel.Info, "Starting application.")

With this NLog.Config:

<?xml version="1.0" encoding="utf-8" ?>
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="true"
      internalLogFile="c:\temp\nlog-internal.log" >

  <targets>
    <target name="file"
            xsi:type="File"
            fileName="${basedir}/Logs\log.txt"
            layout="${longdate}|${level:uppercase=true}|${logger}|${message}"/>
    <target xsi:type="FormControl"
            name="FormControl"
            layout="${longdate}|${level:uppercase=true}|${logger}|${message}"
            append= 'true'
            controlName="TxtBxLog"
            formName="frmMain" />
    <target name="console"
            xsi:type="Console"
            layout="${longdate}|${level:uppercase=true}|${logger}|${message}" /> 
    <!-- <target xsi:type="Memory" name="memory" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" /> -->
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="file" />
    <logger name="FO_DicomExpress.frmMain" minlevel="Trace" writeTo="FormControl" /> 
    <logger name="*" minlevel="Trace" writeTo="console" />
  </rules>
</nlog>



Here is a sample console log that I would like to display in a textbox.

  Dicom.Log.LogManager.SetImplementation(NLogManager.Instance)

2016-06-10 17:46:13.4371|INFO|FO_DicomExpress.frmMain|Starting application.
2016-06-10 17:46:31.2439|INFO|Dicom.Network|CALLED_AE -> Association request:
Calling AE Title:       CALLING_AE
Called AE Title:        CALLED_AE
Implementation Class:   Implementation Class UID [1.3.6.1.4.1.30071.8]
Implementation Version: fo-dicom 2.0.2
Maximum PDU Length:     16384
Async Ops Invoked:      0
Async Ops Performed:    0
Presentation Contexts:  1
  Presentation Context:  1 [Proposed]
       Abstract Syntax:  Modality Worklist Information Model - FIND
       Transfer Syntax:  Explicit VR Little Endian
       Transfer Syntax:  Implicit VR Little Endian: Default Transfer Syntax for DICOM
2016-06-10 17:46:31.2598|INFO|Dicom.Network|CALLED_AE <- Association accept:
Calling AE Title:       CALLING_AE
Called AE Title:        CALLED_AE
Implementation Class:   Unknown [1.2.826.0.1.3680043.2.1545.3]
Implementation Version: 3.0.0
Maximum PDU Length:     16384
Async Ops Invoked:      1
Async Ops Performed:    1
Presentation Contexts:  1
  Presentation Context:  1 [Accept]
       Abstract Syntax:  Modality Worklist Information Model - FIND
       Transfer Syntax:  Implicit VR Little Endian: Default Transfer Syntax for DICOM
2016-06-10 17:46:31.2858|INFO|Dicom.Network|CALLED_AE -> C-Find request [1]
2016-06-10 17:46:31.5297|INFO|Dicom.Network|CALLED_AE <- C-Find response [1]: Pending
2016-06-10 17:46:32.1574|INFO|Dicom.Network|CALLED_AE <- C-Find response [1]: Success
2016-06-10 17:46:32.2245|INFO|Dicom.Network|CALLED_AE -> Association release request
2016-06-10 17:46:32.2245|INFO|Dicom.Network|CALLED_AE <- Association release response
2016-06-10 17:46:32.4414|INFO|Dicom.Network|Connection closed

Anders Gustafsson Cureos AB

unread,
Jun 12, 2016, 5:11:01 PM6/12/16
to Fellow Oak DICOM
Hi David,

I am no expert in the FormControl target, but shouldn't the name attribute in the FormControl logger be set to for example * or Dicom.Network (if you want to delimit your output to networking? I.e. like this:

    <logger name="*" minlevel="Trace" writeTo="FormControl" /> 

Regards,
Anders @ Cureos

David Wetelainen

unread,
Jun 12, 2016, 9:15:08 PM6/12/16
to Fellow Oak DICOM
Hi Anders,

So while I was making changes to NLog.config from within Visual Studio, I forgot the important step of copying the modified config file to bin\debug or bin\release folder to be read when running the application. 

Once I remembered to copy the file and following your suggestion, this now works!

<logger name="*" minlevel="Trace" writeTo="formcontrol" /> 

Thank you for your reply

David W

Bined Abd Elhafid

unread,
Mar 30, 2024, 9:55:13 PMMar 30
to Fellow Oak DICOM
HI
if i want to show logs on the console
Reply all
Reply to author
Forward
0 new messages