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

Logging from within the migration #680

Closed
LSTANCZYK opened this issue Nov 24, 2015 · 5 comments
Closed

Logging from within the migration #680

LSTANCZYK opened this issue Nov 24, 2015 · 5 comments
Labels
feature A new feature (we all like those) logging Logging/Announcer
Milestone

Comments

@LSTANCZYK
Copy link

I would like to be able to log information from inside of the migration. This should be included in the output log. Is this currently possible and if not, please consider it as a feature request.

@sjorsmiltenburg
Copy link

I would also like to know this..

@eloekset
Copy link
Member

eloekset commented Jun 2, 2016

I don't think it's possible. I've been using Console.WriteLine() from within my migrations, but that obviously works when run in a console runner only.

@sjorsmiltenburg
Copy link

sjorsmiltenburg commented Oct 18, 2016

what I did was create a custom announcer which writes to log4net.
this way the normal output is logged to log4net and I can log myself during a migration using log.Debug

`public class Log4netAnnouncer : Announcer
{
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

    public override void Write(string message, bool escaped)
    {
        Log.Debug(message);
    }

    public override void Error(Exception exception)
    {
        base.Error(exception);
        Log.Error(exception);
    }
}`

@fubar-coder
Copy link
Member

fubar-coder commented Mar 31, 2018

I think about using Microsoft.Extensions.Logging and Microsoft.Extensions.DepencencyInjection. This would allow log message filtering and DI for migrations, which would be a solution for this problem.

@fubar-coder fubar-coder added the feature A new feature (we all like those) label Mar 31, 2018
@fubar-coder fubar-coder added this to the Backlog milestone Mar 31, 2018
@fubar-coder fubar-coder added the logging Logging/Announcer label Mar 31, 2018
@fubar-coder fubar-coder modified the milestones: Backlog, 3.0.0 Apr 15, 2018
@fubar-coder
Copy link
Member

Fixed in develop branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature (we all like those) logging Logging/Announcer
Projects
None yet
Development

No branches or pull requests

4 participants