How to log dcmnet level info

All other questions regarding DCMTK

Moderator: Moderator Team

Message
Author
st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

How to log dcmnet level info

#1 Post by st80rules »

Hi,

my app uses dcmtk, and it has a debug mode where I log various info.

With 3.5.4 I used to include the low-level dcmtk debug info to the log, but with the latest snapshot I fail to see how with the new OFLog pattern.

How can I activate debugging of the dcmnet level APIs?

Thanks,

Normand

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#2 Post by st80rules »

Sorry, I meant to say:

"How can I activate logging of the dcmnet level APIs"

Normand

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#3 Post by st80rules »

Hmm,

to be more precise, I did this:

OFLog::configure(OFLogger::TRACE_LOG_LEVEL);

(I also tried DEBUG_LOG_LEVEL)

early in my code.

Then I invoke my app:

myApp >>someFile.txt

someFile.txt does not contain any low-level debug info. It contains very minimal info.

Yet if I add that same line to findscu.cc and recompile it, the output is very verbose.

What am I doing wrong? Is it the redirection?

Normand

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

The code line looks ok to be, but for findscu you should of course use the command line option "-ll trace" or an appropriate config file for the logger.
Btw, redirecting the output to a file is only the second best way. The best way would be something like filelog.cfg.

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#5 Post by st80rules »

Well I don't want to rely on an external file to get debug info.

I'm stumped.

Adding this line to findscu.cc

OFLog::configure(OFLogger::TRACE_LOG_LEVEL);

gives me expected results (a detailed trace); while adding the same line of code to my app does not give me the same results.

What could be wrong?

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#6 Post by Jörg Riesmeier »

Maybe, the logger is reconfigured later in your program? Of course, you can also configure the logger completely from your program (see documentation).

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#7 Post by st80rules »

no, nobody reconfigures the logger (unless it's dcmtk code).

I did discover though that the logger returned by

OFLog::getLogger("dcmtk.dcmnet");

has a log level of NOT_SET_LOG_LEVEL.

Since we can't directly change a logger's level, how do I change its log level?

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#8 Post by st80rules »

OK I've been at this for hours and it's driving me crazy, so I'll postpone it until Monday.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#9 Post by Jörg Riesmeier »

OFLog::configure(OFLogger::TRACE_LOG_LEVEL); works for me, so I have no idea why it does not work for you. Maybe, you should debug your code ...

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#10 Post by st80rules »

But it's not my code... it's the dcmtk code.

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#11 Post by Michael Onken »

Hi,

Maybe post a minimal example of code that should work but does not; that would be help guiding you further.

Best regards,
Michael

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#12 Post by st80rules »

I only add one line of code, as I'm trying to have my app generate a very detailed trace of dcmtk activity:

OFLog::configure(OFLogger::TRACE_LOG_LEVEL);

yet invoking my app with a redirect like this:

myApp >>output.txt

results in a very minimal trace. I added the exact same line to findscu.cc and invoking the recompiled version of findscu with the same redirect as above results in a complete trace.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#13 Post by Jörg Riesmeier »

It seems that we go round in circles ...

So here are a couple of precise questions - please answer them if appropriate:
  • Which operating system are you using and which shell (if there are multiple available)?
  • Have you already tried to omit the redirect, i.e. output to the console? Please note the difference between stdout and stderr.
  • Where in your code are you calling OFLog::configure(), in main() or in the constructor of a global variable?
  • What do you mean by "very minimal trace"? Are you seeing log messages on "trace" level at all?
  • From which DCMTK modules (i.e. loggers) are the messages you can see and which ones are missing?
  • How do you output your own log messages (if any)?

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

#14 Post by Uli Schlachter »

I did a quick-and-dirty test. This was added at the beginning of "main()":

Code: Select all

OFLog::configure(OFLogger::TRACE_LOG_LEVEL);
OFLOG_TRACE(OFLog::getLogger("dcmtk.dcmnet"), "test");
exit(0);
This does work as expected, however redirecting the output via ">>" doesn't work, because the output happens on stderr and not on stdout. If you want to redirect stderr, use "2>>".
For example:

Code: Select all

$ echo test > test
$ cat abcdef 2>> test
$ cat test
test
cat: abcdef No such file or directory

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#15 Post by st80rules »

>>Which operating system are you using and which shell (if there are multiple available)?

Windows XP.

>>Have you already tried to omit the redirect, i.e. output to the console? Please note the difference between stdout and stderr.

No. But as I said, the redirect works fine with findscu.

>>Where in your code are you calling OFLog::configure(), in main() or in the constructor of a global variable?

Much later than in the main(), it's in the initialization phase of the dialog that manages communication with PACS servers.

>>What do you mean by "very minimal trace"? Are you seeing log messages on "trace" level at all? and From which DCMTK modules (i.e. loggers) are the messages you can see and which ones are missing?

The trace only contains this:

Move SCU RQ: MsgID 5
Request:

# Dicom-Data-Set
# Used TransferSyntax: Unknown Transfer Syntax
(0008,0018) UI [1.2.840.113619.2.234.60338626539.1133.1228730122903.5543] # 56, 1 SOPInstanceUID
(0008,0052) CS [IMAGE] # 6, 1 QueryRetrieveLevel
(0020,000d) UI [1.2.840.113619.2.234.60338626539.1133.1228730110290.4974] # 56, 1 StudyInstanceUID
(0020,000e) UI [1.2.840.113619.2.234.60338626539.1133.1228730114510.5165] # 56, 1 SeriesInstanceUID
===================== INCOMING DIMSE MESSAGE ====================
Message Type : C-MOVE RSP
Message ID Being Responded To : 5
Affected SOP Class UID : MOVEStudyRootQueryRetrieveInformationModel
Remaining Suboperations : 0
Completed Suboperations : 1
Failed Suboperations : 0
Warning Suboperations : 0
Data Set : none
DIMSE Status : 0x0000: Success
======================= END DIMSE MESSAGE =======================

Everything from the dcmnet logger is missing.

>>How do you output your own log messages (if any)?

I do not use stderr or stdout, I open a log file and write directly there. My intention was not to share the same output as dcmtk.

Thanks

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest