Search code examples
jquerydotnetnuke

Create a log file for a custom DNN module


We have a search module on DNN and would like to create a log file which will send search terms which did not bring back any matches.

The log will will then have to be emailed to the admin (Perhaps the DNN schedule manager can be used?).

I see that DNN has Log4Net, but won't it be better to write a txt file and write to it?

Does anyone have suggestions on how the Paths to save the file would work and if there are any existing DNN functionality I can use?


Solution

  • You can also use your DotNetNuke.log4net.config

    Example writing to multiple files:

    <log4net>
    <appender name="File1Appender" type="log4net.Appender.FileAppender">
        <file value="log-file-1.txt" />
        <appendToFile value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %message%newline" />
        </layout>
    </appender>
    <appender name="File2Appender" type="log4net.Appender.FileAppender">
        <file value="log-file-2.txt" />
        <appendToFile value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %message%newline" />
        </layout>
    </appender>
    
    <root>
        <level value="DEBUG" />
        <appender-ref ref="File1Appender" />
        <appender-ref ref="File2Appender" />
    </root>