Use Serilog throughout GameServer#64
Open
SzymonKaminski wants to merge 3 commits intothemeldingwars:masterfrom
Open
Use Serilog throughout GameServer#64SzymonKaminski wants to merge 3 commits intothemeldingwars:masterfrom
SzymonKaminski wants to merge 3 commits intothemeldingwars:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've modified logging configuration of GameServer.
By default logs are still shown in console, but they can be sent to Seq and/or saved to files in
logs/directory.It's also possible to filter logs by game systems and change global log level after startup (using Seq).
System names are extracted from namespaces: Aptitude, Entities, Network, Data, Physics, etc.
New App.config file settings:
serilog:write-toaccepts comma delimited values:Console,Seq,File,Noneserilog:system-level:<SystemName>controls min level of logs withinNetworkor any other systemAs a reminder, built-in settings:
serilog:minimum-levelcontrols global min level of logsserilog:minimum-level:override:GameServer.Entitiescontrols min level of logs withinGameServer.EntitiesSourceContextGeneral rule applies - the logging level can only be raised for sinks or systems, not lowered.
If the logger's
MinimumLevelis set toInformationthen a sink withDebugas its specified level will still only seeInformationlevel events.Min log level per sink can be configured using these built-in settings:
serilog:write-to:Console.restrictedToMinimumLevelserilog:write-to:File.restrictedToMinimumLevelserilog:write-to:Seq.restrictedToMinimumLevelThe settings use default key names from sink extensions to ease discovery, but enabling logger sinks is done in
GameServerModuleentirely,therefore adding
<add key="serilog:using:File" value="Serilog.Sinks.File" />and so on is not needed or recommended.This hybrid configuration was done because not all settings can be configured directly in App.config file.
System name is extracted from log's
SourceContext, which is most of the time target class' namespace:It's
PhysicsforGameServer.PhysicsorChatforGameServer.Systems.Chat.In some places it is overriden ad hoc with class from namespace of expected system.
For example
_logger.ForContext<AbilitySystem>().Debug(...)inCombatControllerwill belong toAptitudesystem,because full name of class used in
ForContextisGameServer.Aptitude.AbilitySystem.System overrides can be defined in
GameServer.Logging.LogSystemEnricher.For now I've added only
{ "Shared.Udp.PacketServer", "Network" }to assign verbose logs from
Channel,NetworkClient, and other classes using logger fromPacketServer, toNetworksystem.Seq is log server/viewer tool, can be used to search and filter logs by systems or any parameter appearing in log message, it's free to use locally.
I've added compose file with its container, to start it run
docker compose -p pin -f docker/compose.yaml up -dSeq UI will be available at
http://localhost:8081, admin auth is disabled by default.To change log level dynamically select "Data -> Ingestion" from the top right menu, then click on "Unathenticated" and choose new "Minimum level", then save.
To list all logs from Aptitude type
System = 'Aptitude'; to list all systems of sent logs useselect distinct(System) from stream.