I added those Nuget Packages to my WPF App:
The logger is logging in a file, that works. But no data is transferred to Azure. I got this error:
My Question: Where (in the code) should i initialize the telemetry channel? And why do i have to do this? What's the appender for if i have to add a telemetry client (with config) anyways?
Update 0603:
my app.config:
Debug with visual studio:
Update: please follow the screenshot below, and try to find the info you send. And if you still cannot find the info, please provide you detailed code(remove the personal/important data like instrumentation key, and also provide us the nuget package and version you're using).
1.click the search button in overview page:
2.in the search screen, make the Local time and Event types are set correctly, then try to search the message:
You'd better provide the code to set log4net and app insights key.
I did a simple test with wpf project, the below code works fine:
public partial class MainWindow : Window
{
private static readonly ILog log = LogManager.GetLogger(typeof(MainWindow));
public MainWindow()
{
TelemetryConfiguration.Active.InstrumentationKey = "the key";
log4net.Config.XmlConfigurator.Configure();
log.Info("wpf aaaa11111");
InitializeComponent();
}
}
You get the error "AI: Server telemetry channel was not initialized", maybe due to some incorrect configuration, like use the following code in the above working code:
//when add the code, it will cause the error you mentioned.
TelemetryConfiguration.Active.TelemetryChannel = new ServerTelemetryChannel();
If you have to add a telemetry client (with config), and with proper configuration, both log4net and telemetry client can send data to application insights. The code like below:
public partial class MainWindow : Window
{
private readonly TelemetryClient telemetryClient;
private static readonly ILog log = LogManager.GetLogger(typeof(MainWindow));
public MainWindow()
{
//configure the key here for log4net
TelemetryConfiguration.Active.InstrumentationKey = "the key";
log4net.Config.XmlConfigurator.Configure();
var config = new TelemetryConfiguration();
//configure the key here for telemetry client
config.InstrumentationKey = "the key";
telemetryClient = new TelemetryClient(config);
log.Info("wpf aaaa333");
log.Info(TelemetryConfiguration.Active.TelemetryChannel.ToString());
telemetryClient.TrackTrace("it is going to start!");
InitializeComponent();
}
}