简体   繁体   中英

nlog doesn't work with wp7 emulator

I am working on wp7.1 app and I want to log some actions. I chose nlog for this. I downloaded the latest nlog version and set config file exactly like it is described in this tutorial . So log target is LogReceiverService . To receive messages I use NLogReceiverForwarderService , which is a simple service example included in nlog source code.

The problem is no messages are displayed when I try to log something on wp7 - just console window with "Host opened" message is shown.

I created WPF app with the same nlog config file and it works fine - all messages are logged.

So I am sure that receive service works and config file is correct.

Also:

  • I checked that nlog config is set as Content and it is copied to output directory.
  • I run Visual Studio and WP7 emulator as administrator.
  • I enabled emulator console and set nlog target to Console - no luck. Console opens, some debug information is displayed but no my log messages.

Maybe is too obvious... Check the log level you're using.

I used nuget package manager to install the library in my project. You don't have to worry about how the config file is embedded and you get the dependencies automatically.

This is my nlog config file for console target:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
    <target xsi:type="Console"  name="console" layout="${longdate} ${callsite} ${level} ${message}" header="-----------------"/>          
  </targets>
  <rules>
    <logger name="*" minlevel="Debug" writeTo="console" />
  </rules>
</nlog>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM