diff --git a/Jellyfin.Api/Controllers/ClientLogController.cs b/Jellyfin.Api/Controllers/ClientLogController.cs
index 95d07c9307..98fd224307 100644
--- a/Jellyfin.Api/Controllers/ClientLogController.cs
+++ b/Jellyfin.Api/Controllers/ClientLogController.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Net.Mime;
+using System.Net.Mime;
using System.Threading.Tasks;
using Jellyfin.Api.Attributes;
using Jellyfin.Api.Constants;
@@ -7,7 +6,6 @@ using Jellyfin.Api.Helpers;
using Jellyfin.Api.Models.ClientLogDtos;
using MediaBrowser.Controller.ClientEvent;
using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Model.ClientLog;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -37,54 +35,6 @@ namespace Jellyfin.Api.Controllers
_serverConfigurationManager = serverConfigurationManager;
}
- ///
- /// Post event from client.
- ///
- /// The client log dto.
- /// Event logged.
- /// Event logging disabled.
- /// Submission status.
- [HttpPost]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- [ProducesResponseType(StatusCodes.Status403Forbidden)]
- public ActionResult LogEvent([FromBody] ClientLogEventDto clientLogEventDto)
- {
- if (!_serverConfigurationManager.Configuration.AllowClientLogUpload)
- {
- return Forbid();
- }
-
- var (clientName, clientVersion, userId, deviceId) = GetRequestInformation();
- Log(clientLogEventDto, userId, clientName, clientVersion, deviceId);
- return NoContent();
- }
-
- ///
- /// Bulk post events from client.
- ///
- /// The list of client log dtos.
- /// All events logged.
- /// Event logging disabled.
- /// Submission status.
- [HttpPost("Bulk")]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- [ProducesResponseType(StatusCodes.Status403Forbidden)]
- public ActionResult LogEvents([FromBody] ClientLogEventDto[] clientLogEventDtos)
- {
- if (!_serverConfigurationManager.Configuration.AllowClientLogUpload)
- {
- return Forbid();
- }
-
- var (clientName, clientVersion, userId, deviceId) = GetRequestInformation();
- foreach (var dto in clientLogEventDtos)
- {
- Log(dto, userId, clientName, clientVersion, deviceId);
- }
-
- return NoContent();
- }
-
///
/// Upload a document.
///
@@ -111,39 +61,20 @@ namespace Jellyfin.Api.Controllers
return StatusCode(StatusCodes.Status413PayloadTooLarge, $"Payload must be less than {MaxDocumentSize:N0} bytes");
}
- var (clientName, clientVersion, _, _) = GetRequestInformation();
+ var (clientName, clientVersion) = GetRequestInformation();
var fileName = await _clientEventLogger.WriteDocumentAsync(clientName, clientVersion, Request.Body)
.ConfigureAwait(false);
return Ok(new ClientLogDocumentResponseDto(fileName));
}
- private void Log(
- ClientLogEventDto dto,
- Guid userId,
- string clientName,
- string clientVersion,
- string deviceId)
- {
- _clientEventLogger.Log(new ClientLogEvent(
- dto.Timestamp,
- dto.Level,
- userId,
- clientName,
- clientVersion,
- deviceId,
- dto.Message));
- }
-
- private (string ClientName, string ClientVersion, Guid UserId, string DeviceId) GetRequestInformation()
+ private (string ClientName, string ClientVersion) GetRequestInformation()
{
var clientName = ClaimHelpers.GetClient(HttpContext.User) ?? "unknown-client";
var clientVersion = ClaimHelpers.GetIsApiKey(HttpContext.User)
? "apikey"
: ClaimHelpers.GetVersion(HttpContext.User) ?? "unknown-version";
- var userId = ClaimHelpers.GetUserId(HttpContext.User) ?? Guid.Empty;
- var deviceId = ClaimHelpers.GetDeviceId(HttpContext.User) ?? "unknown-device-id";
- return (clientName, clientVersion, userId, deviceId);
+ return (clientName, clientVersion);
}
}
}
diff --git a/Jellyfin.Api/Models/ClientLogDtos/ClientLogEventDto.cs b/Jellyfin.Api/Models/ClientLogDtos/ClientLogEventDto.cs
deleted file mode 100644
index 9bf9be0a46..0000000000
--- a/Jellyfin.Api/Models/ClientLogDtos/ClientLogEventDto.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using Microsoft.Extensions.Logging;
-
-namespace Jellyfin.Api.Models.ClientLogDtos
-{
- ///
- /// The client log dto.
- ///
- public class ClientLogEventDto
- {
- ///
- /// Gets or sets the event timestamp.
- ///
- [Required]
- public DateTime Timestamp { get; set; }
-
- ///
- /// Gets or sets the log level.
- ///
- [Required]
- public LogLevel Level { get; set; }
-
- ///
- /// Gets or sets the log message.
- ///
- [Required]
- public string Message { get; set; } = string.Empty;
- }
-}
diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index 045ed6a2ba..30b6bff9f5 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -44,7 +44,6 @@
-
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 6e4c2280be..7f158aebb4 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -13,7 +13,6 @@ using Emby.Server.Implementations;
using Jellyfin.Server.Implementations;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
-using MediaBrowser.Controller.ClientEvent;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.IO;
using Microsoft.AspNetCore.Hosting;
@@ -26,7 +25,6 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Serilog;
using Serilog.Extensions.Logging;
-using Serilog.Filters;
using SQLitePCL;
using ConfigurationExtensions = MediaBrowser.Controller.Extensions.ConfigurationExtensions;
using ILogger = Microsoft.Extensions.Logging.ILogger;
@@ -598,46 +596,22 @@ namespace Jellyfin.Server
{
// Serilog.Log is used by SerilogLoggerFactory when no logger is specified
Log.Logger = new LoggerConfiguration()
- .WriteTo.Logger(lc =>
- lc.ReadFrom.Configuration(configuration)
- .Enrich.FromLogContext()
- .Enrich.WithThreadId()
- .Filter.ByExcluding(Matching.FromSource()))
- .WriteTo.Logger(lc =>
- lc.WriteTo.Map(
- "ClientName",
- (clientName, wt)
- => wt.File(
- Path.Combine(appPaths.LogDirectoryPath, "log_" + clientName + "_.log"),
- rollingInterval: RollingInterval.Day,
- outputTemplate: "{Message:l}{NewLine}{Exception}",
- encoding: Encoding.UTF8))
- .Filter.ByIncludingOnly(Matching.FromSource()))
+ .ReadFrom.Configuration(configuration)
+ .Enrich.FromLogContext()
+ .Enrich.WithThreadId()
.CreateLogger();
}
catch (Exception ex)
{
Log.Logger = new LoggerConfiguration()
- .WriteTo.Logger(lc =>
- lc.WriteTo.Async(x => x.File(
- Path.Combine(appPaths.LogDirectoryPath, "log_.log"),
- rollingInterval: RollingInterval.Day,
- outputTemplate: "{Message:l}{NewLine}{Exception}",
- encoding: Encoding.UTF8))
- .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss}] [{Level:u3}] [{ThreadId}] {SourceContext}: {Message:lj}{NewLine}{Exception}")
- .Enrich.FromLogContext()
- .Enrich.WithThreadId())
- .WriteTo.Logger(lc =>
- lc
- .WriteTo.Map(
- "ClientName",
- (clientName, wt)
- => wt.File(
- Path.Combine(appPaths.LogDirectoryPath, "log_" + clientName + "_.log"),
- rollingInterval: RollingInterval.Day,
- outputTemplate: "{Message:l}{NewLine}{Exception}",
- encoding: Encoding.UTF8))
- .Filter.ByIncludingOnly(Matching.FromSource()))
+ .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss}] [{Level:u3}] [{ThreadId}] {SourceContext}: {Message:lj}{NewLine}{Exception}")
+ .WriteTo.Async(x => x.File(
+ Path.Combine(appPaths.LogDirectoryPath, "log_.log"),
+ rollingInterval: RollingInterval.Day,
+ outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] [{ThreadId}] {SourceContext}: {Message}{NewLine}{Exception}",
+ encoding: Encoding.UTF8))
+ .Enrich.FromLogContext()
+ .Enrich.WithThreadId()
.CreateLogger();
Log.Logger.Fatal(ex, "Failed to create/read logger configuration");
diff --git a/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs b/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs
index 82b5b4593c..dea1c2f32a 100644
--- a/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs
+++ b/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs
@@ -1,47 +1,23 @@
using System;
using System.IO;
using System.Threading.Tasks;
-using MediaBrowser.Model.ClientLog;
-using Microsoft.Extensions.Logging;
namespace MediaBrowser.Controller.ClientEvent
{
///
public class ClientEventLogger : IClientEventLogger
{
- private const string LogString = "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level}] [{ClientName}:{ClientVersion}]: UserId: {UserId} DeviceId: {DeviceId}{NewLine}{Message}";
- private readonly ILogger _logger;
private readonly IServerApplicationPaths _applicationPaths;
///
/// Initializes a new instance of the class.
///
- /// Instance of the interface.
/// Instance of the interface.
- public ClientEventLogger(
- ILogger logger,
- IServerApplicationPaths applicationPaths)
+ public ClientEventLogger(IServerApplicationPaths applicationPaths)
{
- _logger = logger;
_applicationPaths = applicationPaths;
}
- ///
- public void Log(ClientLogEvent clientLogEvent)
- {
- _logger.Log(
- LogLevel.Critical,
- LogString,
- clientLogEvent.Timestamp,
- clientLogEvent.Level.ToString(),
- clientLogEvent.ClientName,
- clientLogEvent.ClientVersion,
- clientLogEvent.UserId ?? Guid.Empty,
- clientLogEvent.DeviceId,
- Environment.NewLine,
- clientLogEvent.Message);
- }
-
///
public async Task WriteDocumentAsync(string clientName, string clientVersion, Stream fileContents)
{
diff --git a/MediaBrowser.Controller/ClientEvent/IClientEventLogger.cs b/MediaBrowser.Controller/ClientEvent/IClientEventLogger.cs
index 34968d493e..ad8a1bd249 100644
--- a/MediaBrowser.Controller/ClientEvent/IClientEventLogger.cs
+++ b/MediaBrowser.Controller/ClientEvent/IClientEventLogger.cs
@@ -1,7 +1,5 @@
using System.IO;
using System.Threading.Tasks;
-using MediaBrowser.Controller.Net;
-using MediaBrowser.Model.ClientLog;
namespace MediaBrowser.Controller.ClientEvent
{
@@ -10,12 +8,6 @@ namespace MediaBrowser.Controller.ClientEvent
///
public interface IClientEventLogger
{
- ///
- /// Logs the event from the client.
- ///
- /// The client log event.
- void Log(ClientLogEvent clientLogEvent);
-
///
/// Writes a file to the log directory.
///