Skip to content

Commit 6c29f29

Browse files
committed
Enable Raven.Embedded console and file logging
1 parent f41f69b commit 6c29f29

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/ServiceControl.RavenDB/EmbeddedDatabase.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace ServiceControl.RavenDB
1515
using Raven.Client.Documents.Conventions;
1616
using Raven.Client.ServerWide.Operations;
1717
using Raven.Embedded;
18+
using Sparrow.Logging;
1819

1920
public sealed class EmbeddedDatabase : IDisposable
2021
{
@@ -52,6 +53,16 @@ public static EmbeddedDatabase Start(EmbeddedDatabaseConfiguration databaseConfi
5253

5354
var nugetPackagesPath = Path.Combine(databaseConfiguration.DbPath, "Packages", "NuGet");
5455

56+
LoggingSource.Instance.SetupLogMode(
57+
(LogMode)255,
58+
Path.Combine(databaseConfiguration.LogPath, "Raven.Embedded"),
59+
retentionTime: TimeSpan.FromDays(14),
60+
retentionSize: 1024 * 1024 * 10,
61+
compress: false
62+
);
63+
64+
LoggingSource.Instance.EnableConsoleLogging();
65+
5566
Logger.InfoFormat("Loading RavenDB license from {0}", licenseFileNameAndServerDirectory.LicenseFileName);
5667
var serverOptions = new ServerOptions
5768
{
@@ -191,13 +202,13 @@ public async Task Stop(CancellationToken cancellationToken)
191202
{
192203
try
193204
{
194-
Logger.Warn("Killing RavenDB child process because host cancelled");
205+
Logger.WarnFormat("Killing RavenDB server PID {0} child process because host cancelled", processId);
195206
var ravenChildProcess = Process.GetProcessById(processId);
196207
ravenChildProcess.Kill(entireProcessTree: true);
197208
}
198209
catch (Exception e)
199210
{
200-
Logger.Error("Killing RavenDB child process failed", e);
211+
Logger.ErrorFormat("Failed to kill RavenDB server PID {0}\n{1}", processId, e);
201212
}
202213
}
203214

@@ -263,6 +274,7 @@ static long DataSize(EmbeddedDatabaseConfiguration configuration)
263274
{
264275
return -1;
265276
}
277+
266278
return info.Length;
267279
}
268280
catch

0 commit comments

Comments
 (0)