How to see the logs if we have deployed our Spring Boot Application in Google Cloud Platform?












0















We have developed a Spring Boot application and deployed in Google Cloud Platform (GCP). It is Compute Engine and we have Ubuntu 16.04.5 LTS as Operating System and Apache Tomcat 8.5.3 as Web Server.



In this application, we have used System.out.println() statements and sometimes we are throwing the exceptions as well.




Now I want to see the logs which are generated by either System.out.println() or through the Exceptions but how to see the console in Google Cloud Platform?











share|improve this question



























    0















    We have developed a Spring Boot application and deployed in Google Cloud Platform (GCP). It is Compute Engine and we have Ubuntu 16.04.5 LTS as Operating System and Apache Tomcat 8.5.3 as Web Server.



    In this application, we have used System.out.println() statements and sometimes we are throwing the exceptions as well.




    Now I want to see the logs which are generated by either System.out.println() or through the Exceptions but how to see the console in Google Cloud Platform?











    share|improve this question

























      0












      0








      0








      We have developed a Spring Boot application and deployed in Google Cloud Platform (GCP). It is Compute Engine and we have Ubuntu 16.04.5 LTS as Operating System and Apache Tomcat 8.5.3 as Web Server.



      In this application, we have used System.out.println() statements and sometimes we are throwing the exceptions as well.




      Now I want to see the logs which are generated by either System.out.println() or through the Exceptions but how to see the console in Google Cloud Platform?











      share|improve this question














      We have developed a Spring Boot application and deployed in Google Cloud Platform (GCP). It is Compute Engine and we have Ubuntu 16.04.5 LTS as Operating System and Apache Tomcat 8.5.3 as Web Server.



      In this application, we have used System.out.println() statements and sometimes we are throwing the exceptions as well.




      Now I want to see the logs which are generated by either System.out.println() or through the Exceptions but how to see the console in Google Cloud Platform?








      java spring tomcat google-cloud-platform ubuntu-16.04






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 17:26









      AltafAltaf

      3610




      3610
























          1 Answer
          1






          active

          oldest

          votes


















          2














          You cannot see the logs in GCP directly via System.out.println or Exceptions



          There are two ways to achieve this:



          Possible but not recommended: Use filewriter to write logs into a file, access the file and read it



          Recommended: Add logger into your application.
          For this, include apache commons logging into your application's pom.xml



          <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.2</version>
          </dependency>


          Write logs as per requirement:



          @RestController    
          public class ExampleController {
          private static final Log LOGGER = LogFactory.getLog(ExampleController.class);

          @RequestMapping("/<custom-url>")
          public String function() {
          String message = "Example message written to the log";
          String secondMessage = "Second example written to the log";
          LOGGER.info(message);
          LOGGER.info(secondMessage);
          return message;
          }
          }


          You can use Logger into as many functions and as many controllers you like, it will be added to the same Logger and will be displayed collaboratively.



          Now you will be able to see logs in your GCP's project Log tab :)



          P.S. This will file log as info. You can use error or other classification options available to classify your log message type. For that, replace info with any following options to classify:



          Log classifications



          Any log level will display all types of logs.






          share|improve this answer
























          • Suppose, I have 30 Controllers then do I need to write this line private static final Log LOGGER = LogFactory.getLog(ExampleController.class); in all the Controllers?

            – Altaf
            Nov 21 '18 at 4:33













          • Yes, you will need to . Just the classname would change. E.g. ExampleController.class will get replaced by <ControllerClassName>.class

            – Abhishek Anand
            Nov 22 '18 at 4:26











          • I have used Apache Commons Logging but how to see the logs in Compute Engine google cloud platform. Please reply

            – Altaf
            Nov 22 '18 at 12:35











          • in the gcp console, when you log in to project, you can find logger in the menu as this: imgur.com/a/z0oCn5c

            – Abhishek Anand
            Nov 23 '18 at 19:06











          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%2f53398359%2fhow-to-see-the-logs-if-we-have-deployed-our-spring-boot-application-in-google-cl%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









          2














          You cannot see the logs in GCP directly via System.out.println or Exceptions



          There are two ways to achieve this:



          Possible but not recommended: Use filewriter to write logs into a file, access the file and read it



          Recommended: Add logger into your application.
          For this, include apache commons logging into your application's pom.xml



          <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.2</version>
          </dependency>


          Write logs as per requirement:



          @RestController    
          public class ExampleController {
          private static final Log LOGGER = LogFactory.getLog(ExampleController.class);

          @RequestMapping("/<custom-url>")
          public String function() {
          String message = "Example message written to the log";
          String secondMessage = "Second example written to the log";
          LOGGER.info(message);
          LOGGER.info(secondMessage);
          return message;
          }
          }


          You can use Logger into as many functions and as many controllers you like, it will be added to the same Logger and will be displayed collaboratively.



          Now you will be able to see logs in your GCP's project Log tab :)



          P.S. This will file log as info. You can use error or other classification options available to classify your log message type. For that, replace info with any following options to classify:



          Log classifications



          Any log level will display all types of logs.






          share|improve this answer
























          • Suppose, I have 30 Controllers then do I need to write this line private static final Log LOGGER = LogFactory.getLog(ExampleController.class); in all the Controllers?

            – Altaf
            Nov 21 '18 at 4:33













          • Yes, you will need to . Just the classname would change. E.g. ExampleController.class will get replaced by <ControllerClassName>.class

            – Abhishek Anand
            Nov 22 '18 at 4:26











          • I have used Apache Commons Logging but how to see the logs in Compute Engine google cloud platform. Please reply

            – Altaf
            Nov 22 '18 at 12:35











          • in the gcp console, when you log in to project, you can find logger in the menu as this: imgur.com/a/z0oCn5c

            – Abhishek Anand
            Nov 23 '18 at 19:06
















          2














          You cannot see the logs in GCP directly via System.out.println or Exceptions



          There are two ways to achieve this:



          Possible but not recommended: Use filewriter to write logs into a file, access the file and read it



          Recommended: Add logger into your application.
          For this, include apache commons logging into your application's pom.xml



          <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.2</version>
          </dependency>


          Write logs as per requirement:



          @RestController    
          public class ExampleController {
          private static final Log LOGGER = LogFactory.getLog(ExampleController.class);

          @RequestMapping("/<custom-url>")
          public String function() {
          String message = "Example message written to the log";
          String secondMessage = "Second example written to the log";
          LOGGER.info(message);
          LOGGER.info(secondMessage);
          return message;
          }
          }


          You can use Logger into as many functions and as many controllers you like, it will be added to the same Logger and will be displayed collaboratively.



          Now you will be able to see logs in your GCP's project Log tab :)



          P.S. This will file log as info. You can use error or other classification options available to classify your log message type. For that, replace info with any following options to classify:



          Log classifications



          Any log level will display all types of logs.






          share|improve this answer
























          • Suppose, I have 30 Controllers then do I need to write this line private static final Log LOGGER = LogFactory.getLog(ExampleController.class); in all the Controllers?

            – Altaf
            Nov 21 '18 at 4:33













          • Yes, you will need to . Just the classname would change. E.g. ExampleController.class will get replaced by <ControllerClassName>.class

            – Abhishek Anand
            Nov 22 '18 at 4:26











          • I have used Apache Commons Logging but how to see the logs in Compute Engine google cloud platform. Please reply

            – Altaf
            Nov 22 '18 at 12:35











          • in the gcp console, when you log in to project, you can find logger in the menu as this: imgur.com/a/z0oCn5c

            – Abhishek Anand
            Nov 23 '18 at 19:06














          2












          2








          2







          You cannot see the logs in GCP directly via System.out.println or Exceptions



          There are two ways to achieve this:



          Possible but not recommended: Use filewriter to write logs into a file, access the file and read it



          Recommended: Add logger into your application.
          For this, include apache commons logging into your application's pom.xml



          <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.2</version>
          </dependency>


          Write logs as per requirement:



          @RestController    
          public class ExampleController {
          private static final Log LOGGER = LogFactory.getLog(ExampleController.class);

          @RequestMapping("/<custom-url>")
          public String function() {
          String message = "Example message written to the log";
          String secondMessage = "Second example written to the log";
          LOGGER.info(message);
          LOGGER.info(secondMessage);
          return message;
          }
          }


          You can use Logger into as many functions and as many controllers you like, it will be added to the same Logger and will be displayed collaboratively.



          Now you will be able to see logs in your GCP's project Log tab :)



          P.S. This will file log as info. You can use error or other classification options available to classify your log message type. For that, replace info with any following options to classify:



          Log classifications



          Any log level will display all types of logs.






          share|improve this answer













          You cannot see the logs in GCP directly via System.out.println or Exceptions



          There are two ways to achieve this:



          Possible but not recommended: Use filewriter to write logs into a file, access the file and read it



          Recommended: Add logger into your application.
          For this, include apache commons logging into your application's pom.xml



          <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.2</version>
          </dependency>


          Write logs as per requirement:



          @RestController    
          public class ExampleController {
          private static final Log LOGGER = LogFactory.getLog(ExampleController.class);

          @RequestMapping("/<custom-url>")
          public String function() {
          String message = "Example message written to the log";
          String secondMessage = "Second example written to the log";
          LOGGER.info(message);
          LOGGER.info(secondMessage);
          return message;
          }
          }


          You can use Logger into as many functions and as many controllers you like, it will be added to the same Logger and will be displayed collaboratively.



          Now you will be able to see logs in your GCP's project Log tab :)



          P.S. This will file log as info. You can use error or other classification options available to classify your log message type. For that, replace info with any following options to classify:



          Log classifications



          Any log level will display all types of logs.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 17:53









          Abhishek AnandAbhishek Anand

          1366




          1366













          • Suppose, I have 30 Controllers then do I need to write this line private static final Log LOGGER = LogFactory.getLog(ExampleController.class); in all the Controllers?

            – Altaf
            Nov 21 '18 at 4:33













          • Yes, you will need to . Just the classname would change. E.g. ExampleController.class will get replaced by <ControllerClassName>.class

            – Abhishek Anand
            Nov 22 '18 at 4:26











          • I have used Apache Commons Logging but how to see the logs in Compute Engine google cloud platform. Please reply

            – Altaf
            Nov 22 '18 at 12:35











          • in the gcp console, when you log in to project, you can find logger in the menu as this: imgur.com/a/z0oCn5c

            – Abhishek Anand
            Nov 23 '18 at 19:06



















          • Suppose, I have 30 Controllers then do I need to write this line private static final Log LOGGER = LogFactory.getLog(ExampleController.class); in all the Controllers?

            – Altaf
            Nov 21 '18 at 4:33













          • Yes, you will need to . Just the classname would change. E.g. ExampleController.class will get replaced by <ControllerClassName>.class

            – Abhishek Anand
            Nov 22 '18 at 4:26











          • I have used Apache Commons Logging but how to see the logs in Compute Engine google cloud platform. Please reply

            – Altaf
            Nov 22 '18 at 12:35











          • in the gcp console, when you log in to project, you can find logger in the menu as this: imgur.com/a/z0oCn5c

            – Abhishek Anand
            Nov 23 '18 at 19:06

















          Suppose, I have 30 Controllers then do I need to write this line private static final Log LOGGER = LogFactory.getLog(ExampleController.class); in all the Controllers?

          – Altaf
          Nov 21 '18 at 4:33







          Suppose, I have 30 Controllers then do I need to write this line private static final Log LOGGER = LogFactory.getLog(ExampleController.class); in all the Controllers?

          – Altaf
          Nov 21 '18 at 4:33















          Yes, you will need to . Just the classname would change. E.g. ExampleController.class will get replaced by <ControllerClassName>.class

          – Abhishek Anand
          Nov 22 '18 at 4:26





          Yes, you will need to . Just the classname would change. E.g. ExampleController.class will get replaced by <ControllerClassName>.class

          – Abhishek Anand
          Nov 22 '18 at 4:26













          I have used Apache Commons Logging but how to see the logs in Compute Engine google cloud platform. Please reply

          – Altaf
          Nov 22 '18 at 12:35





          I have used Apache Commons Logging but how to see the logs in Compute Engine google cloud platform. Please reply

          – Altaf
          Nov 22 '18 at 12:35













          in the gcp console, when you log in to project, you can find logger in the menu as this: imgur.com/a/z0oCn5c

          – Abhishek Anand
          Nov 23 '18 at 19:06





          in the gcp console, when you log in to project, you can find logger in the menu as this: imgur.com/a/z0oCn5c

          – Abhishek Anand
          Nov 23 '18 at 19:06




















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398359%2fhow-to-see-the-logs-if-we-have-deployed-our-spring-boot-application-in-google-cl%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

          鏡平學校

          ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

          Why https connections are so slow when debugging (stepping over) in Java?