Serendipity
Serendipity

Reputation: 13

DotNetNuke Event Logging format

Using DotNetNuke 5. I am using the EventLogController along with LogInfo to add custom messages to the event logs in dot net nuke.

Within LogInfo we have a method to Add a Property/Value. I am under the assumption that the Controller.AddLog(logInfo) converts the properties & vlaues into XML using the LogInfo->Serialize method for DNN to store it.

My problem is that I want linebreaks in my message. Is there anyway I can add a newline. "\r\n" wouldn't work,
wouldn't work, CDATA escaped wouldn't work. Everything gets escaped through the Log function.

How do I pretty print the log message myself?

Regards, V

Upvotes: 1

Views: 1397

Answers (2)

Mitchel Sellers
Mitchel Sellers

Reputation: 63126

Sadly, due to the HTML encoding that is done on all messages, you are going to be out of luck trying to do this in the DNN event Log.

Depending on what/where you are, you have a few options.

  1. You can add them as individual detail lines using properties, see my example below.
  2. You could report on something yourself, using a custom log table or something similar
  3. If you are in the context of a Scheduled Job, you can log to that history, which is NOT escaped.

Examples

Log Properties

objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
objLog.AddProperty("SecureMyInstall", "Phase 2 Error Processing User Accounts");
objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
objLogger.AddLog(objLog);

Upvotes: 3

bdukes
bdukes

Reputation: 156005

The content of the logs is displayed as HTML, so you should be able to put <br /> to add line breaks.

Upvotes: 1

Related Questions