<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sri </title>
    <description>The latest articles on DEV Community by Sri  (@s_srikamini_bfb9ce2df10).</description>
    <link>https://dev.to/s_srikamini_bfb9ce2df10</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3868750%2Fcf1f8f04-508b-4e05-9ac2-2e6cf7d82124.webp</url>
      <title>DEV Community: Sri </title>
      <link>https://dev.to/s_srikamini_bfb9ce2df10</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/s_srikamini_bfb9ce2df10"/>
    <language>en</language>
    <item>
      <title>SpringBoot Basic Annotations and Logging</title>
      <dc:creator>Sri </dc:creator>
      <pubDate>Thu, 09 Apr 2026 12:49:38 +0000</pubDate>
      <link>https://dev.to/s_srikamini_bfb9ce2df10/springboot-basic-annotations-and-logging-11ci</link>
      <guid>https://dev.to/s_srikamini_bfb9ce2df10/springboot-basic-annotations-and-logging-11ci</guid>
      <description>&lt;p&gt;Today we learned yo create a spring project in Spring initializer.&lt;br&gt;
Here we learnt metadata is data about data, some of metadata in maven is artifact,groupid and version.&lt;br&gt;
we also learned about maven project structure and adding spring web dependency. Spring web gives tomcat automatically, whereas in eclipse we as a programmer explicitly add apache tomcat server and bring it up. spring web helps to withhold tomcat server and container takes care of bringing the server up. it helps developer to concentrate on business log instead of working in bringing the server up. Its a great feature of spring boot. &lt;/p&gt;

&lt;p&gt;Exploring logs:&lt;br&gt;
application.properties&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;server.port = 8080 //port in which localhost will be accessed&lt;/li&gt;
&lt;li&gt;logging.level.root=INFO //logger prints all abstract information into the console.&lt;/li&gt;
&lt;li&gt;logging.level.root=DEBUG // It prints all debug informations.errors.and INFO into the console.&lt;/li&gt;
&lt;li&gt;logging.level.root=TRACE// It prints fine-grained logic flow.
5.logging.level.com.spring.LearningDemo = DEBUG //If we want to print only our package logs, we can do it.
6.If we want to have a external logging file in local disk we use below code in application.properties.
logging.file.name = myapp.log
logging.file.path="/E:Spring projects/LearningDemo"&lt;/li&gt;
&lt;li&gt;In production we use logging.level.root=INFO to avoid unneccesary loggings. we use DEBUG only when we want identify a bug.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;context pat is  the base URL of app. here &lt;a href="http://localhost:8080/index" rel="noopener noreferrer"&gt;http://localhost:8080/index&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Annotations:&lt;br&gt;
@Controller &lt;br&gt;
Container idetifies the mentioned class as container using this annotation.&lt;/p&gt;

&lt;p&gt;@Controller&lt;br&gt;
public class LearningFrontController {&lt;br&gt;&lt;br&gt;
    public String getResponseFromLearningFrontController(){&lt;br&gt;
       return "Welcome to SpringBootFrontController";&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
In core Java programmer has to initialise an object to call any method from one class to another. whereas in spring and spring boot container takes of creating instances, programmer can concentrate on the business logic.&lt;br&gt;
A project can have any no of controllers, we can differentiate them using requestmapping annotaion.&lt;/p&gt;

&lt;p&gt;@Controller&lt;br&gt;
@RequestMapping("First")&lt;br&gt;
public class LearningFrontController {&lt;br&gt;
    private static final Logger log= LoggerFactory.getLogger(LearningFrontController.class);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public String getResponseFromLearningFrontController(){
log.info("LearningFrontController started");
log.debug("Debug:LearningFrontController started");
log.debug("Debug:LearningFrontController completed");
return "Welcome to SpringBootFrontController";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
similarly  a single container can have any no of methods so we exlplicitly differentiate the method using @RequestMapping("/add")&lt;/p&gt;

&lt;p&gt;@RequestMapping("/add/{a}/{b}")&lt;br&gt;
    @ResponseBody&lt;br&gt;
    public String getAddResponseFromLearningFrontController(@PathVariable int a,@PathVariable int b){&lt;br&gt;
        log.info("LearningFrontController started");&lt;br&gt;
        log.debug("Debug:LearningFrontController started");&lt;br&gt;
        int c=a+b;&lt;br&gt;
        log.debug("Debug:LearningFrontController completed");&lt;br&gt;
        log.debug("Debug:LearningFrontController completed");&lt;br&gt;
        return "Addition is "+c;&lt;br&gt;
    }&lt;br&gt;
This method usually returns the view name and view resolver returns it to the client but when we want to return and value and inform the container to print the returned value as content of the page, we use "@ResponseBody" &lt;br&gt;
@RequestMapping("/Login/{username}/{password}")&lt;br&gt;
        //@ResponseBody&lt;br&gt;
        public String Login(@PathVariable String username,@PathVariable String password)&lt;br&gt;
        {&lt;br&gt;
            log.debug("Debug:welcomeUser started");&lt;br&gt;
            String name1 =username;&lt;br&gt;
            log.debug("Debug:welcomeUser completed");&lt;br&gt;
            return "welcome "+username;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;@Pathvariable: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;user is sending input to the method in URL.&lt;/li&gt;
&lt;li&gt;Service will fetch the input from the url and handles in method when @Pathvariable is mentioned.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;@RestController &lt;br&gt;
Combination of both Responsebody and controller.&lt;br&gt;
when all methods in the container uses response body, then we can mention one annotation at the top of the controller.&lt;br&gt;
@RestController&lt;br&gt;
@RequestMapping("/second")&lt;br&gt;
public class LearningFrontREquestController {&lt;br&gt;
        private static final Logger log= LoggerFactory.getLogger(com.learning.LearningDemo.LearningFrontController.class);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public String getResponseFromLearningFrontController(){
        log.info("LearningFrontController started");
        log.debug("Debug:LearningFrontRequstController started");
        log.debug("Debug:LearningFrontrequstController completed");
        return "Welcome to SpringBootFrontController";
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>backend</category>
      <category>beginners</category>
      <category>java</category>
      <category>springboot</category>
    </item>
  </channel>
</rss>
