Skip to content
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

Switch logging level for CommandExecuted and CommandExecuting #18351

Merged
merged 1 commit into from
Oct 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EFCore.Design/Design/Internal/OperationLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public virtual void Log<TState>(
{
// Only show SQL when verbose
if (_categoryName == DbLoggerCategory.Database.Command.Name
&& eventId.Id == RelationalEventId.CommandExecuting.Id)
&& eventId.Id == RelationalEventId.CommandExecuted.Id)
{
logLevel = LogLevel.Debug;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/EFCore.Relational/Properties/RelationalStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@
</data>
<data name="LogExecutingCommand" xml:space="preserve">
<value>Executing DbCommand [Parameters=[{parameters}], CommandType='{commandType}', CommandTimeout='{commandTimeout}']{newLine}{commandText}</value>
<comment>Information RelationalEventId.CommandExecuting string System.Data.CommandType int string string</comment>
<comment>Debug RelationalEventId.CommandExecuting string System.Data.CommandType int string string</comment>
</data>
<data name="LogExecutedCommand" xml:space="preserve">
<value>Executed DbCommand ({elapsed}ms) [Parameters=[{parameters}], CommandType='{commandType}', CommandTimeout='{commandTimeout}']{newLine}{commandText}</value>
<comment>Debug RelationalEventId.CommandExecuted string string System.Data.CommandType int string string</comment>
<comment>Information RelationalEventId.CommandExecuted string string System.Data.CommandType int string string</comment>
</data>
<data name="LogCommandFailed" xml:space="preserve">
<value>Failed executing DbCommand ({elapsed}ms) [Parameters=[{parameters}], CommandType='{commandType}', CommandTimeout='{commandTimeout}']{newLine}{commandText}</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Design.Internal
public class OperationLoggerTests
{
[ConditionalFact]
public void Log_dampens_logLevel_when_CommandExecuting()
public void Log_dampens_logLevel_when_CommandExecuted()
{
var reporter = new TestOperationReporter();
var loggerFactory = new LoggerFactory();
Expand All @@ -20,7 +20,7 @@ public void Log_dampens_logLevel_when_CommandExecuting()
var logger = loggerFactory.CreateLogger(DbLoggerCategory.Database.Command.Name);
logger.Log<object>(
LogLevel.Information,
RelationalEventId.CommandExecuting,
RelationalEventId.CommandExecuted,
null,
null,
(_, __) => "-- Can't stop the SQL");
Expand Down
8 changes: 4 additions & 4 deletions test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ public async Task Logs_commands_without_parameter_values(

Assert.Equal(LogLevel.Debug, logFactory.Log[0].Level);
Assert.Equal(LogLevel.Debug, logFactory.Log[1].Level);
Assert.Equal(LogLevel.Information, logFactory.Log[2].Level);
Assert.Equal(LogLevel.Debug, logFactory.Log[3].Level);
Assert.Equal(LogLevel.Debug, logFactory.Log[2].Level);
Assert.Equal(LogLevel.Information, logFactory.Log[3].Level);

foreach (var (_, _, message, _, _) in logFactory.Log.Skip(2))
{
Expand Down Expand Up @@ -1017,8 +1017,8 @@ public async Task Logs_commands_parameter_values(
CoreResources.LogSensitiveDataLoggingEnabled(new TestLogger<TestRelationalLoggingDefinitions>()).GenerateMessage(),
logFactory.Log[2].Message);

Assert.Equal(LogLevel.Information, logFactory.Log[3].Level);
Assert.Equal(LogLevel.Debug, logFactory.Log[4].Level);
Assert.Equal(LogLevel.Debug, logFactory.Log[3].Level);
Assert.Equal(LogLevel.Information, logFactory.Log[4].Level);

foreach (var (_, _, message, _, _) in logFactory.Log.Skip(3))
{
Expand Down