-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to see messages properly in event viewer #169
Comments
The message You're filling The second The attribute you set in the The above may or may not be the source of the problem, but still worth fixing. As for the problem with the messages, from my past memory, this is usually related to issues with .dll registration (e.g. the .dll with message resources is not registered or not found where it was registered). |
I corrected the I have cross checked the possibility of DLL registration issues but everything looks OK there. I even tried using I have removed the lines in my source code where I was setting the "Message" attribute. I have added the template string for Regarding the
but if I try to use these values in type_mapping the way I have it already, I get a runtime error at the following statement: this is the error:
this is because make_event expects only enum event_type values which does not have the value "3" defined.
|
Yes, that's correct. The incorrect part was trying to use the severity constants as event types. As was said in the other issue, those are different things, don't mix them. If the dll with message resources is registered correctly and accessible then I don't have any specific ideas. The event is clearly sent, and it has the expected type and id. The problem is Windows not translating the id to the message text. A few things to check:
I'm not using Windows or event log at all, so I won't be able to help much, sorry. Let me know if you find out what the issue is. |
Any updates? Is this still relevant? |
I wasn't able to get it working. I switched to simple_event_log_backend and living with it for now. |
Hi,
Following are my environment details:
I am using Boost Library version 1.77.0
I am using Windows 10 operating system.
I am using Visual Studio 2019.
The platform toolset is v142
C++ language standard: ISO C++ 17 (/std:c++17)
C Language standard: ISO C 17 (2018) (/std:c17)
My project is a DLL project where I am using event logging
I am also using the following macro: #define BOOST_ALL_DYN_LINK
I am using custom event logging as described in the following link:
https://www.boost.org/doc/libs/1_77_0/libs/log/example/event_log/main.cpp
I have created a custom message configuration file with the following content:
`
; /* --------------------------------------------------------
; HEADER SECTION
; */
SeverityNames=(Debug=0x0:AUTO_SCORE_SEVERITY_DEBUG
Info=0x0:AUTO_SCORE_SEVERITY_INFO
Warning=0x2:AUTO_SCORE_SEVERITY_WARNING
Error=0x1:AUTO_SCORE_SEVERITY_ERROR
)
; /* --------------------------------------------------------
; MESSAGE DEFINITION SECTION
; */
MessageIdTypedef=WORD
MessageId=0x1
SymbolicName=CATEGORY_DEBUG
Language=English
Debug Message
.
MessageId=0x2
SymbolicName=CATEGORY_INFO
Language=English
Info Message
.
MessageId=0x3
SymbolicName=CATEGORY_WARNING
Language=English
Warning Message
.
MessageId=0x4
SymbolicName=CATEGORY_ERROR
Language=English
Error Message
.
MessageIdTypedef=DWORD
MessageId=0x100
Severity=Debug
Facility=Application
SymbolicName=DEBUG_MSG
Language=English
[%1][%2]: %3
.
MessageId=0x101
Severity=Info
Facility=Application
SymbolicName=INFO_MSG
Language=English
.
MessageId=0x102
Severity=Warning
Facility=Application
SymbolicName=WARNING_MSG
Language=English
[%1][%2]: %3
.
MessageId=0x103
Severity=Error
Facility=Application
SymbolicName=ERROR_MSG
Language=English
[%1][%2]: %3
.
`
The logging header file looks like this:
`
#pragma once
#include
#include
#include
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/posix_time_io.hpp>
#include <boost/log/common.hpp>
#include <boost/log/attributes.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/event_log_backend.hpp>
#include "autoscore_eventlog_provider/autoscore_eventlog_provider.h"
// Check windows
#if _WIN32 || _WIN64
#if _WIN64
#define ENVIRONMENT64
#else
#define ENVIRONMENT32
#endif
#endif
// Check GCC
#if GNUC
#if x86_64 || ppc64
#define ENVIRONMENT64
#else
#define ENVIRONMENT32
#endif
#endif
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
namespace autoscore::log
{
namespace logging = boost::log;
namespace attrs = boost::log::attributes;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;
namespace expr = boost::log::expressions;
namespace keywords = boost::log::keywords;
}
`
The logging implementation file looks like this:
`
#include "pch.h"
#include "autoscore_log.h"
namespace autoscore::log
{
void init_win_event_log(config const logging_config)
{
// Create an event log sink
boost::shared_ptr< sinks::event_log_backend > backend(
new sinks::event_log_backend((
keywords::message_file = logging_config.message_file, //%APPDATA%\Holberg EEG AS\autoSCORE\Logs\autoscore_eventlog_provider.dll
keywords::log_name = logging_config.log_name, //Holberg EEG AS
keywords::log_source = logging_config.log_source //autoSCORE
))
);
}
`
I have created the header file and definitions DLL based on the *.mc file and created the registry keys by running the DLL consumer application as administrator.
I am able to see the events in the event viewer but without any content. I am attaching screen shots of how it looks like.
I am not sure what is my mistake. Can some one help m
e?
The text was updated successfully, but these errors were encountered: