How to write error logs from command prompt to a file in protractor












1














I am using protractor-cucumber frame work. I am running my protractor script by the command protractor conf.js from the command prompt. I need to write the error logs from the command prompt to a external .log file after the execution of the protractor script. How can I catch this command prompt output to a file through the code. I need to get the logs in both command prompt and in an external .log file for which we should give the .log file path in the code).










share|improve this question
























  • Have you tried redirecting the standard output?
    – betontalpfa
    Nov 12 at 8:09










  • Please read this post.
    – betontalpfa
    Nov 12 at 8:19










  • Thanks for your reply. Redirecting the standard output is working for me, but what I need is if the test failed then only need to write the error logs to another file. I am able to identify whether the test failed or passed through the code, But I am not able to write the error logs in the command prompt to an another file through the code.
    – Mathews Mathew
    Nov 12 at 8:59










  • @betontalpfa, i am doing like appending the logs of each test run.I am using protractor conf.js >> F:logslog.txt ,the logs are writing to the log.txt but i am not able to identify the date here.So how can we identify each logs by date?
    – Devleena
    Nov 12 at 9:45
















1














I am using protractor-cucumber frame work. I am running my protractor script by the command protractor conf.js from the command prompt. I need to write the error logs from the command prompt to a external .log file after the execution of the protractor script. How can I catch this command prompt output to a file through the code. I need to get the logs in both command prompt and in an external .log file for which we should give the .log file path in the code).










share|improve this question
























  • Have you tried redirecting the standard output?
    – betontalpfa
    Nov 12 at 8:09










  • Please read this post.
    – betontalpfa
    Nov 12 at 8:19










  • Thanks for your reply. Redirecting the standard output is working for me, but what I need is if the test failed then only need to write the error logs to another file. I am able to identify whether the test failed or passed through the code, But I am not able to write the error logs in the command prompt to an another file through the code.
    – Mathews Mathew
    Nov 12 at 8:59










  • @betontalpfa, i am doing like appending the logs of each test run.I am using protractor conf.js >> F:logslog.txt ,the logs are writing to the log.txt but i am not able to identify the date here.So how can we identify each logs by date?
    – Devleena
    Nov 12 at 9:45














1












1








1


0





I am using protractor-cucumber frame work. I am running my protractor script by the command protractor conf.js from the command prompt. I need to write the error logs from the command prompt to a external .log file after the execution of the protractor script. How can I catch this command prompt output to a file through the code. I need to get the logs in both command prompt and in an external .log file for which we should give the .log file path in the code).










share|improve this question















I am using protractor-cucumber frame work. I am running my protractor script by the command protractor conf.js from the command prompt. I need to write the error logs from the command prompt to a external .log file after the execution of the protractor script. How can I catch this command prompt output to a file through the code. I need to get the logs in both command prompt and in an external .log file for which we should give the .log file path in the code).







protractor cucumberjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 8:29









betontalpfa

8351023




8351023










asked Nov 12 at 7:41









Mathews Mathew

214




214












  • Have you tried redirecting the standard output?
    – betontalpfa
    Nov 12 at 8:09










  • Please read this post.
    – betontalpfa
    Nov 12 at 8:19










  • Thanks for your reply. Redirecting the standard output is working for me, but what I need is if the test failed then only need to write the error logs to another file. I am able to identify whether the test failed or passed through the code, But I am not able to write the error logs in the command prompt to an another file through the code.
    – Mathews Mathew
    Nov 12 at 8:59










  • @betontalpfa, i am doing like appending the logs of each test run.I am using protractor conf.js >> F:logslog.txt ,the logs are writing to the log.txt but i am not able to identify the date here.So how can we identify each logs by date?
    – Devleena
    Nov 12 at 9:45


















  • Have you tried redirecting the standard output?
    – betontalpfa
    Nov 12 at 8:09










  • Please read this post.
    – betontalpfa
    Nov 12 at 8:19










  • Thanks for your reply. Redirecting the standard output is working for me, but what I need is if the test failed then only need to write the error logs to another file. I am able to identify whether the test failed or passed through the code, But I am not able to write the error logs in the command prompt to an another file through the code.
    – Mathews Mathew
    Nov 12 at 8:59










  • @betontalpfa, i am doing like appending the logs of each test run.I am using protractor conf.js >> F:logslog.txt ,the logs are writing to the log.txt but i am not able to identify the date here.So how can we identify each logs by date?
    – Devleena
    Nov 12 at 9:45
















Have you tried redirecting the standard output?
– betontalpfa
Nov 12 at 8:09




Have you tried redirecting the standard output?
– betontalpfa
Nov 12 at 8:09












Please read this post.
– betontalpfa
Nov 12 at 8:19




Please read this post.
– betontalpfa
Nov 12 at 8:19












Thanks for your reply. Redirecting the standard output is working for me, but what I need is if the test failed then only need to write the error logs to another file. I am able to identify whether the test failed or passed through the code, But I am not able to write the error logs in the command prompt to an another file through the code.
– Mathews Mathew
Nov 12 at 8:59




Thanks for your reply. Redirecting the standard output is working for me, but what I need is if the test failed then only need to write the error logs to another file. I am able to identify whether the test failed or passed through the code, But I am not able to write the error logs in the command prompt to an another file through the code.
– Mathews Mathew
Nov 12 at 8:59












@betontalpfa, i am doing like appending the logs of each test run.I am using protractor conf.js >> F:logslog.txt ,the logs are writing to the log.txt but i am not able to identify the date here.So how can we identify each logs by date?
– Devleena
Nov 12 at 9:45




@betontalpfa, i am doing like appending the logs of each test run.I am using protractor conf.js >> F:logslog.txt ,the logs are writing to the log.txt but i am not able to identify the date here.So how can we identify each logs by date?
– Devleena
Nov 12 at 9:45












1 Answer
1






active

oldest

votes


















0














if you are using jasmine, You should try below code



SpecDone: function(execResult) {
for(var i = 0; i < execResult.failedExpectations.length; i++) {
console.log('Failure: ' + execResult.failedExpectations[i].message);
console.log(execResult.failedExpectations[i].stack);
}
}





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257715%2fhow-to-write-error-logs-from-command-prompt-to-a-file-in-protractor%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    if you are using jasmine, You should try below code



    SpecDone: function(execResult) {
    for(var i = 0; i < execResult.failedExpectations.length; i++) {
    console.log('Failure: ' + execResult.failedExpectations[i].message);
    console.log(execResult.failedExpectations[i].stack);
    }
    }





    share|improve this answer


























      0














      if you are using jasmine, You should try below code



      SpecDone: function(execResult) {
      for(var i = 0; i < execResult.failedExpectations.length; i++) {
      console.log('Failure: ' + execResult.failedExpectations[i].message);
      console.log(execResult.failedExpectations[i].stack);
      }
      }





      share|improve this answer
























        0












        0








        0






        if you are using jasmine, You should try below code



        SpecDone: function(execResult) {
        for(var i = 0; i < execResult.failedExpectations.length; i++) {
        console.log('Failure: ' + execResult.failedExpectations[i].message);
        console.log(execResult.failedExpectations[i].stack);
        }
        }





        share|improve this answer












        if you are using jasmine, You should try below code



        SpecDone: function(execResult) {
        for(var i = 0; i < execResult.failedExpectations.length; i++) {
        console.log('Failure: ' + execResult.failedExpectations[i].message);
        console.log(execResult.failedExpectations[i].stack);
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 at 12:26









        Yash Jagdale

        1,059812




        1,059812






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257715%2fhow-to-write-error-logs-from-command-prompt-to-a-file-in-protractor%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues