SpringBoot(APIサーバー) + Vue.js(フロント)でWebアプリの開発をおこなっています。
現在、Vue→SpringBootへのAPI通信時のエラー内容などをconsole.log(error)
のような形でブラウザ上で確認していますが、このconsole.log
の内容を.log形式のファイルとしてサーバー側に外部出力することは可能でしょうか?
【処理のサンプル】
sample.vue
1const AXIOS = axios.create({ 2 baseURL: process.env.VUE_APP_PUBLIC_PATH + "api", 3 timeout: 100000, 4}); 5 6export api { 7 sample(data) { 8 return AXIOS.get("/sample/" + data); 9 } 10} 11 12// 通信時のアクション 13// この処理内のconsole.logで出力している箇所をサーバーにファイルとして外部出力したい。 14 15api 16 .sample(this.data) 17 .then((response) => { 18 if (response.data.success) { 19 try { 20 sessionStorage.setItem("userData", JSON.stringify(response.data.json)); 21 sessionStorage.setItem("keyName", JSON.stringify(response.data.message)); 22 } catch(e) { 23 // sessionStorageが使えなければエラーページに遷移 24 console.log("error:" + e); 25 this.$router.push({ 26 name: "error", 27 params: { kind: "unex", code: "01" }, 28 }); 29 } 30 this.$router.push({ 31 name: "identity_information", 32 }); 33 } else { 34 this.$router.push({ 35 name: "error", 36 params: { kind: response.data.message, code: response.data.code }, 37 }); 38 } 39 }) 40 .catch((error) => { 41 console.log(error); 42 this.$router.push({ 43 name: "error", 44 params: { kind: "unex", code: "01" }, 45 }); 46 });