Replace Default WordPress Logo with the Current Theme Logo in WordPress Login Page

Solution:

Please, try this one

function my_custom_login_logo() {
    $logo_url = ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) ? wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ) : false;
    $logo_url = ( $logo_url ) ? $logo_url[0] : generate_get_option( 'logo' );

    $logo_url = esc_url( apply_filters( 'generate_logo', $logo_url ) );

    ?>
    <style type="text/css">
        h1 a {
            background-image:url(<?php echo $logo_url ?>) !important; margin:0 auto;}
    </style>
    <?php
}
add_filter( 'login_head', 'my_custom_login_logo' );